Format date
Function: Format date
This function helps you change how a date looks. You can transform a date into a specific text format, like showing only the year and month, or convert it into a numerical representation called "Epoch milliseconds." This is useful for displaying dates in a user-friendly way or for preparing dates for integration with other systems.
Input
- Date: The date you want to reformat. This is a required input. (Type: DATE)
- Date format: (Optional) If you choose "Free format" for the "Format type," this is where you define the pattern for your date. For example,
yyyy-MM-dd HH:mm:sswould display a date as2023-01-31 12:00:00. You can useyfor year,Mfor month,dfor day,Hfor hour,mfor minute, andsfor second. If left blank for "Free format," the date will be formatted using a standard ISO format (e.g.,2023-07-04T10:00:00). (Type: STRING) - Format type: (Optional) Choose how you would like to format the date.
- Free format: Allows you to specify a custom
Date formatstring. This is the default option. - Epoch milliseconds: Converts the date into a single number representing the milliseconds that have passed since January 1, 1970, 00:00:00 GMT. (Type: SELECT_ONE)
- Free format: Allows you to specify a custom
Output
- Name: This is the name you give to the variable that will hold the formatted date. For example, if you enter
MyDateString, the result will be stored in a variable namedMyDateString. By default, this name isFORMATTED_DATE. (Type: STRING)- The actual output of this function is the formatted date (as text or a number), which will be assigned to the variable name you provide.
Execution Flow
Real-Life Examples
-
Example 1: Displaying a date in a user-friendly format for a report
- Inputs:
- Date:
2023-10-26 14:30:00 - Date format:
dd/MM/yyyy HH:mm - Format type:
Free format - Name:
ReportDate
- Date:
- Result: The variable
ReportDatewill contain the text26/10/2023 14:30. This could be used to display a transaction date on an invoice or a report header.
- Inputs:
-
Example 2: Converting a date for system integration with a third-party API
- Inputs:
- Date:
2024-01-15 09:00:00 - Format type:
Epoch milliseconds - Name:
ApiTimestamp
- Date:
- Result: The variable
ApiTimestampwill contain a number like1705309200000. This is useful when sending date information to external systems that expect a numerical timestamp.
- Inputs:
-
Example 3: Formatting a date with only the month and year for a summary dashboard
- Inputs:
- Date:
2025-03-10 11:45:00 - Date format:
MMMM yyyy - Format type:
Free format - Name:
DashboardMonthYear
- Date:
- Result: The variable
DashboardMonthYearwill contain the textMarch 2025. This could be used for report headers or summaries where only the month and year are relevant.
- Inputs:
-
Example 4: Using the default "Free format" for a standard date representation
- Inputs:
- Date:
2023-07-04 10:00:00 - Date format: (Left blank)
- Format type:
Free format - Name:
StandardDateString
- Date:
- Result: The variable
StandardDateStringwill contain the text2023-07-04T10:00:00. This is useful for standard date representations when no custom format is specified, often used for logging or internal system records.
- Inputs: