Ask AI
Skip to main content

Format date

Function: Format date

This function allows you to take a date and transform it into a specific text format. You can choose from predefined formats or create your own custom pattern to display the date and time exactly how you need it, or convert it into a numerical representation (Epoch milliseconds). This is useful for displaying dates in reports, user interfaces, or for integrating with other systems that require specific date formats.

Input

  • Date: The original date you want to format. This is a required input.
  • Date format: (Optional) A custom pattern to define how the date should appear. You can use letters like y for year, M for month, d for day, H for hour, m for minute, and s for second. For example, yyyy-MM-dd HH:mm:ss would format a date like 2023-01-31 12:00:00. If you leave this blank and choose "Free format", a standard date and time format will be used.
  • Format type: (Optional) Choose how you want to format the date.
    • Free format: Allows you to use a custom date format pattern or a standard default. (This is the default choice).
    • Epoch milliseconds: Converts the date into a single number representing the total milliseconds since January 1, 1970, 00:00:00 GMT.

Output

  • Name: The name of the variable where the formatted date (as text) will be stored. By default, this will be FORMATTED_DATE.

Execution Flow

Real-Life Examples

Example 1: Displaying a date in a user-friendly report

Scenario: You have a date representing an order placement and want to display it in a report as "January 31, 2023 at 10:30 AM".

Inputs:

  • Date: 2023-01-31T10:30:00Z (or a date variable from your application)
  • Date format: MMMM dd, yyyy 'at' hh:mm a
  • Format type: Free format
  • Name: OrderDateFormatted

Result: A new variable named OrderDateFormatted will be created, containing the text value "January 31, 2023 at 10:30 AM".

Example 2: Storing a date for system integration

Scenario: You need to send a date to an external system that expects the date in a standard YYYY-MM-DD format.

Inputs:

  • Date: 2024-07-15T14:45:30Z
  • Date format: yyyy-MM-dd
  • Format type: Free format
  • Name: IntegrationDate

Result: A new variable named IntegrationDate will be created, containing the text value "2024-07-15".

Example 3: Converting a date to a numerical timestamp

Scenario: You need to calculate the duration between two events, and for this, you need to convert a specific date into its Epoch milliseconds representation.

Inputs:

  • Date: 2023-01-01T00:00:00Z
  • Date format: (Leave blank)
  • Format type: Epoch milliseconds
  • Name: StartDateEpoch

Result: A new variable named StartDateEpoch will be created, containing a numerical value like 1672531200000.