How to Enter Today's Date as a Field in a Google Sheet?

This topic was automatically generated from Slack. You can find the original thread here.

how do I enter today’s date as a field if I’m filling out a google sheet as one of the steps

To enter today’s date as a field when filling out a Google Sheet in a Pipedream workflow, you can use JavaScript’s Date object to get the current date and format it as needed. Below is an example of how you might write a Pipedream component code step to achieve this. This example assumes you’re using a pre-built Google Sheets action to insert data into your sheet and focuses on preparing today’s date to be used as a field value. ```
export default defineComponent({ async run({ steps, $ }) { // Get today’s date const today = new Date(); // Format the date as YYYY-MM-DD (you can adjust the format as needed) const formattedDate = today.toISOString().split(‘T’)[0]; // Now, you can use formattedDate as the value for the date field // when using a Google Sheets action to insert data into your sheet. // For example: // steps.google_sheets_action_name.insertRow({ // spreadsheetId: ‘your_spreadsheet_id’, // range: ‘Sheet1!A1’, // values: [ // [formattedDate, ‘Other field value 1’, ‘Other field value 2’] // ], // }); // Returning formattedDate for demonstration purposes return formattedDate; }, });

So I have to insert a step in my flow, get date first, and then do the rest of the steps? Is there not a way to enter a line of code inside the configuration step?

Another option is to take the pipeline request date and use the Format Date function to transform it.