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.Get Month (gmon)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.gmon Command

Get the numeric month value from a date string

 

Intention

 

This command parses a date string, based on an optional format mask, and extracts the numeric value of the Month component (1-12).

It uses the same underlying logic as DTO.ParseDate but returns only the month value.

 

Syntax

 

DTO.gmon|DateString|[FormatMask]|[$$RES]

DTO.getmonth|...

 

Parameter Explanation

 

P1 - DateString (Required)

The date string (or a variable, e.g., $$DAT) containing the date value.

Example: "25.12.2025"

 

P2 - FormatMask (Optional)

The format mask string (or variable, e.g., $$MSK) describing the structure of P1.

Example: "DD.MM.YYYY". If omitted, a default mask ("DD.MM.YYYY" with '.' separator) is used.

 

P3 - $$RES (Optional)

The variable (e.g., $$RES) where the numeric month value (1-12) will be stored. If omitted, the result is placed on TOS.

 

 

Example

 

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

' DTO.gmon - Sample

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

'

' --- Example 1: Get month using default mask ---

$$DAT = "25.12.2025"

DTO.gmon|$$DAT||$$MON

DBV.Month 1: $$MON ' Result: 12

'

' --- Example 2: Get month using specific mask (MM/DD/YYYY) ---

$$DAT = "07/31/2024"

$$MSK = "MM/DD/YYYY"

DTO.gmon|$$DAT|$$MSK|$$MON

DBV.Month 2: $$MON ' Result: 7

'

' --- Example 3: Invalid Date ---

$$DAT = "30.13.2023"

DTO.gmon|$$DAT||$$MON

DBV.Month 3: $$MON ' Result: 0 (Parsing failed)

'

ENR.

 

Remarks

 

The returned month is always a numeric value between 1 (January) and 12 (December).

If the FormatMask is omitted, the command assumes the standard "DD.MM.YYYY" format.

 

Limitations

 

- If the date string cannot be parsed correctly using the mask (or the default mask), the result will be 0.

 

See also

 

    DTO. - Date Time Operations

    DTO.Parse Date (pdate)

    DTO.Get Day (gday)

    DTO.Get Year (gyea)

    DTO.Format Date (fdate)

    DTO.Make Date Mask (mdm)