|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Operations |
MiniRobotLanguage (MRL)
DTO.gday Command
Get the numeric Day value from a date string
Intention
This command parses a date string, using an optional format mask, and extracts only the numeric value of the **Day** component (1-31).
It utilizes the same underlying logic as DTO.ParseDate but returns only the day value.
Syntax
DTO.gday|DateString|[FormatMask]|[$$RES]
DTO.getday|...
Parameter Explanation
P1 - DateString (Required)
The date string (or a variable, e.g., $$DAT) containing the date value.
Example: "2025-10-20"
P2 - FormatMask (Optional)
The format mask string (or variable) describing the structure of P1.
Example: "YYYY-MM-DD". If omitted, a default mask ("DD.MM.YYYY" with '.' separator) is assumed.
P3 - $$RES (Optional)
The variable (e.g., $$RES) where the numeric day value (1-31) will be stored. If omitted, the result is placed on TOS.
Example
'**********************************************
' DTO.gday - Sample
'**********************************************
'
' --- Example 1: Get day from DD.MM.YYYY ---
$$DAT = "25.12.2025"
DTO.gday|$$DAT||$$DAY
DBV.Day 1: $$DAY ' Result: 25
'
' --- Example 2: Get day from MM/DD/YYYY ---
$$DAT = "10/20/2025"
$$MSK = "MM/DD/YYYY"
DTO.gday|$$DAT|$$MSK|$$DAY
DBV.Day 2: $$DAY ' Result: 20
'
' --- Example 3: Get day from YYYY-MM-DD to TOS ---
DTO.gday|"2024-03-08"|"YYYY-MM-DD"
POP.$$TOS
DBV.Day 3 (TOS): $$TOS ' Result: 8
'
ENR.
Remarks
This provides a convenient way to get just the day component without needing multiple output variables like DTO.ParseDate.
If the FormatMask is omitted, the default "DD.MM.YYYY" is used.
Limitations
- If the date string cannot be parsed correctly using the mask (e.g., invalid date or mismatched format), the result will be 0.
See also
• DTO.Split Date Mask (spdm) - (Old command)