Date & Time Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Date and Time Calculation > DTO. - Date Time Operations >

Date & Time Operations

DTO.Format Date (fdate)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.FormatDate Command

Format date components into a string

 

Intention

 

This command builds a date string from individual numeric components (Day, Month, Year) according to a specified format mask. It's the counterpart to DTO.ParseDate.

 

The format mask defines the output structure using these components:

  YYYY (4-digit year), YY (2-digit year), Y (2-digit year)

  MM (2-digit month), M (1-2 digit month)

  DD (2-digit day), D (1-2 digit day)

 

Syntax

 

DTO.formatdate|$$DAY|$$MON|$$YEA|FormatMask[|$$RES]

DTO.fdate|$$DAY|$$MON|$$YEA|FormatMask[|$$RES]

 

Parameter Explanation

 

P1 - $$DAY (Required)

The numeric value for the Day (1-31) (or a variable, e.g., $$DAY).

 

P2 - $$MON (Required)

The numeric value for the Month (1-12) (or a variable, e.g., $$MON).

 

P3 - $$YEA (Required)

The numeric value for the Year (e.g., 2025) (or a variable, e.g., $$YEA).

 

P4 - FormatMask (Required)

The string mask (or variable) defining the desired output format.

Example: "YYYY-MM-DD"

 

P5 - $$RES (Optional)

The variable (e.g., $$RES) where the formatted date string will be stored. If omitted, the result is placed on TOS.

 

 

Example

 

'**********************************************

' DTO.fdate - Sample

'**********************************************

'

' --- Example 1: Format date components to ISO ---

$$D = 25

$$M = 12

$$Y = 2025

$$MSK = "YYYY-MM-DD"

DTO.fdate|$$D|$$M|$$Y|$$MSK|$$RES

DBV.Result 1: $$RES ' Result: "2025-12-25"

'

' --- Example 2: Format using single digits and different separator ---

$$D = 5

$$M = 3

$$Y = 2024

$$MSK = "M/D/YY"

DTO.fdate|$$D|$$M|$$Y|$$MSK|$$RES

DBV.Result 2: $$RES ' Result: "3/5/24"

'

' --- Example 3: Output to TOS ---

DTO.fdate|1|10|2026|"DD.MM.YYYY"

POP.$$TOS

DBV.Result 3: $$TOS ' Result: "01.10.2026"

'

ENR.

 

Remarks

 

This command is useful for constructing date strings after performing calculations or parsing.

The mask determines the separator and the order/format of the components in the output string.

Using "YY" or "Y" in the mask will output the last two digits of the year.

 

Limitations

 

- The command requires P1-P4 (Day, Month, Year, Mask). It will error if they are not provided.

- Input values are not strictly validated. Providing a day of "32" might produce "32" in the string, rather than an error.

 

See also

 

    DTO. - Date Time Operations

    DTO.Parse Date - parse date into components

    DTO.Split Date Mask - (Old parsing command)

    DTO.Reformat Date - reformat date using mask

    DTO.Format Time - format time components to string

    DTO.Make Date Mask - create date format mask