|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Operations |
MiniRobotLanguage (MRL)
DTO.GetDateSeparator Command
Detect the separator character used in a date string or format mask
Intention
This command identifies the character used to separate the Day, Month, and Year components in a date string or a date format mask. Common separators include '.', '-', '/', '\', and space.
The command prioritizes searching the format mask first. If no separator is found there (or no mask is provided), it then searches the date string. If no separator is found in either, it defaults to "." (dot).
Syntax
DTO.getdateseparator|[DateString]|[FormatMask]|[$$RES]
DTO.gds|[DateString]|[FormatMask]|[$$RES]
Parameter Explanation
P1 - DateString (Optional)
The date string (or a variable, e.g., $$DAT) to examine if P2 does not contain a separator.
Example: "20/10/2025"
P2 - FormatMask (Optional)
The format mask string (or variable, e.g., $$MSK) to check first for a separator.
Example: "YYYY-MM-DD"
P3 - $$RES (Optional)
The variable (e.g., $$RES) where the detected separator character will be stored. If omitted, the result is placed on TOS.
Example
'**********************************************
' DTO.gds - Sample
'**********************************************
'
' --- Example 1: Detect from Format Mask ---
DTO.gds||"YYYY-MM-DD"|$$SEP1
DBV.Separator 1: $$SEP1 ' Result: "-"
'
' --- Example 2: Detect from Date String ---
$$DAT = "20/10/2025"
DTO.gds|$$DAT||$$SEP2
DBV.Separator 2: $$SEP2 ' Result: "/"
'
' --- Example 3: Format Mask takes priority ---
DTO.gds|"20/10/2025"|"DD.MM.YYYY"|$$SEP3
DBV.Separator 3: $$SEP3 ' Result: "." (from the mask)
'
' --- Example 4: No separator found (default) ---
DTO.gds|"20251020"|"YYYYMMDD"|$$SEP4
DBV.Separator 4: $$SEP4 ' Result: "." (default)
'
' --- Example 5: Using TOS ---
DTO.gds|"2025 10 20"
POP.$$TOS
DBV.Separator 5 (from TOS): $$TOS ' Result: " " (space)
'
ENR.
Remarks
The search order is: Format Mask -> Date String -> Default (".").
Characters considered valid separators are checked using the DTO.IsDateSeparator logic. This includes common characters like .-/\, space, and some others.
Providing at least one of P1 or P2 is recommended to get a meaningful result other than the default.
Limitations
- Only the first valid separator found in the prioritized string is returned. If a string contains mixed separators (e.g., "2025-10/20"), only the first one ('-') will be detected.
See also
• DTO.Is Date Separator - check if char is date separator
• DTO.Get Time Separator - detect time separator char
• DTO.Parse Date - parse date into components
• DTO.Make Date Mask - create date format mask