Date & Time Calculations

<< Click to Display Table of Contents >>

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

Date & Time Calculations

DTO.AddToCurrentDate - Add Days to the Current Date

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.AddToCurrentDate Command

Add or Subtract Days from the Current System Date

 

Intention

 

The DTO.AddToCurrentDate command is a convenient shortcut for performing date calculations relative to today. It fetches the current system date and adds a specified number of days to it, returning the new date as a formatted string.

 

You can add days to find a future date (e.g., a delivery date) or subtract days by providing a negative number to find a past date (e.g., a start date for a report). This command simplifies calculating dates like "tomorrow," "yesterday," or "a week from now" without needing multiple commands.

 

Syntax

 

DTO.AddToCurrentDate|days|[format]|[$$RES]

 

Parameter Explanation

 

days - A numeric value indicating the number of days to add. Use a negative value to subtract days.

 

format - (Optional) A format mask for the output date string (e.g., "YYYY-MM-DD"). If omitted, a default format with a '.' separator is used ("DD.MM.YYYY").

 

$$RES - (Optional) The variable where the resulting formatted date string will be stored.

 

Example

 

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

' DTO.AddToCurrentDate - Sample

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

'

' --- Sample 1: Get the date for "tomorrow" ---

DTO.AddToCurrentDate|1||$$TMR

MBX.Tomorrow's date is $$TMR

'

' --- Sample 2: Get the date 30 days ago ---

DTO.AddToCurrentDate|-30||$$AGO

MBX.The date 30 days ago was $$AGO

'

' --- Sample 3: Get the date a week from now in a different format ---

$$FMT = "YYYY/MM/DD"

DTO.AddToCurrentDate|7|$$FMT|$$NXT

MBX.One week from today will be $$NXT

ENR.

 

Remarks

 

This command always uses the computer's current system date as the starting point for its calculation. It cannot be used to add days to an arbitrary date stored in a variable; for that, use the DTO.AddDays command.

 

Limitations:

 

The accuracy of the command depends on the system clock being set correctly.

 

See also:

 

    DTO. - Date Time Operations

    DTO.Add Days

    DTO.Subtract Days

    DTO.Get Current Date

    DTO.Add To Current Time

    DTC. - Date and Time Calculation