Parse date
Function: Parse date
This action helps you convert a date written as text into a standardized date format that your application can easily understand and use. This is useful when you receive dates in various text formats (e.g., from external systems or user input) and need to process them consistently as proper date values.
Input
- Date: The date you want to convert, provided as text. For example, "2023-10-26", "October 26, 2023", or "26/10/2023". This input is required.
- Date format: (Optional) If your text date is in a specific, non-standard format, you can tell the system how to read it. Use letters like
yfor year,Mfor month,dfor day,Hfor hour,mfor minute, andSfor second. For example,yyyy-MM-dd HH:mm:SSwill correctly parse a date like "2023-10-26 14:30:00". If you leave this blank, the system will try to guess common date formats. - Output Variable Name: This is the name you want to give to the new variable that will store the converted date. By default, if you don't specify a name, it will be called
FORMATTED_DATE. This input is required.
Output
- Formatted Date: A
DATEtype value representing the successfully parsed date. This value will be stored in the variable whose name you provided in the "Output Variable Name" input.
Execution Flow
Real-Life Examples
Example 1: Standard Date Conversion
- Scenario: You receive a list of customer orders where the order date is consistently in the "YYYY-MM-DD" format. You need to convert this text into a proper date field for filtering and reporting.
- Inputs:
- Date: "2023-10-26"
- Date format: "yyyy-MM-dd"
- Output Variable Name: "OrderDateParsed"
- Result: A new variable named
OrderDateParsedis created, containing the date valueOctober 26, 2023.
Example 2: Parsing with Time and Default Format
- Scenario: A user enters a booking date and time as "2024-01-15 14:30:00". You want to store this as a date/time object in your application. Since it's a common format, you don't need to specify the format explicitly.
- Inputs:
- Date: "2024-01-15 14:30:00"
- Date format: (Leave blank)
- Output Variable Name: "BookingDateTime"
- Result: A new variable named
BookingDateTimeis created, containing the date and time valueJanuary 15, 2024, 2:30 PM.
Example 3: Converting from a Specific Regional Format
- Scenario: You import data from an old system where dates are stored in a "DD/MM/YYYY" format, which is common in some regions. You need to convert these into a usable date format for your application.
- Inputs:
- Date: "05/12/2022"
- Date format: "dd/MM/yyyy"
- Output Variable Name: "LegacyDate"
- Result: A new variable named
LegacyDateis created, containing the date valueDecember 05, 2022.
Example 4: Handling an Invalid Date Format
- Scenario: A user accidentally enters "October 26th, 2023" but specifies the format as "yyyy-MM-dd", which does not match the input text.
- Inputs:
- Date: "October 26th, 2023"
- Date format: "yyyy-MM-dd"
- Output Variable Name: "MyDate"
- Result: The action will fail and report an error, indicating that the provided date text does not match the specified format. The
MyDatevariable will not be created.