|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Operations |
MiniRobotLanguage (MRL)
DTO.ParseDate Command
Parse a date string into components
Intention
This command extracts the Day, Month, and Year from a given date string. It uses an optional format mask to understand the structure of the date string. If the mask is omitted, it defaults to the standard German format "DD.MM.YYYY".
The format mask components are:
• YYYY (4-digit year), YY (2-digit year - converted to 20YY)
• MM (2-digit month), M (1-2 digit month)
• DD (2-digit day), D (1-2 digit day)
This command is the recommended replacement for the older DTO.splitdate command as it handles the default mask correctly.
Syntax
DTO.parsedate|DateString|[FmtMask]|[$$DAY]|[$$MON]|[$$YER]
DTO.pdate|DateString|[FmtMask]|[$$DAY]|[$$MON]|[$$YER]
Parameter Explanation
P1 - DateString (Required)
The date string (or a variable, e.g., $$DAT) to parse.
P2 - FormatMask (Optional)
The format mask string (or variable, e.g., $$MSK) describing the structure of P1. If omitted, it defaults to "DD.MM.YYYY".
P3 - $$DAY (Optional)
A variable (e.g., $$DAY) to store the extracted Day component (numeric).
P4 - $$MON (Optional)
A variable (e.g., $$MON) to store the extracted Month component (numeric).
P5 - $$YER (Optional)
A variable (e.g., $$YER) to store the extracted Year component (numeric).
Example
'**********************************************
' DTO.pdate - Sample
'**********************************************
'
' --- Example 1: Parse standard German date (default mask) ---
$$DAT = "25.12.2025"
DTO.pdate|$$DAT||$$DAY|$$MON|$$YER
DBV.Day: $$DAY ' Result: 25
DBV.Month: $$MON ' Result: 12
DBV.Year: $$YER ' Result: 2025
'
' --- Example 2: Parse US date (MM/DD/YY) with explicit mask ---
$$USD = "04/15/24"
$$MSK = "MM/DD/YY"
DTO.pdate|$$USD|$$MSK|$$D|$$M|$$Y
DBV.Day: $$D ' Result: 15
DBV.Month: $$M ' Result: 4
DBV.Year: $$Y ' Result: 2024 (YY is converted)
'
' --- Example 3: Only get Year (using default mask) ---
$$DAT = "01.03.2026"
DTO.pdate|$$DAT||||$$YER
DBV.Year: $$YER ' Result: 2026
'
ENR.
Remarks
If the optional format mask (P2) is omitted, the default mask "DD.MM.YYYY" is used.
If a 2-digit year (YY) is parsed, it is automatically converted to a 4-digit year by adding 2000 (e.g., "24" becomes 2024).
If parsing fails (e.g., invalid date string or mismatch with the mask), the output variables ($$DAY, $$MON, $$YER) will contain 0.
Limitations
- The command relies on the structure defined by the mask. It doesn't perform strict validation (e.g., it might parse "31.02.2025" without error, resulting in Day=31, Month=2, Year=2025).
See also
• DTO.Format Date - format date components to string
• DTO.Split Date Mask - (Older command, use ParseDate instead)
• DTO.Make Date Mask - create date format mask
• DTO.Get Date Separator - detect date separator char