<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > Time to Value Commands > Date & Time Calculations |
MiniRobotLanguage (MRL)
VTD. Command
Value to Date
Intention
Using DTV. you can convert a date to the equivalent number of days since January 1601.
Now you can do any sort of math using this number. When you're done, just use VTD. to convert the result back into a valid date!
This way calculations with days get as easy as adding or subtracting numbers.
Example:
VTD.1|$$RES
MBX.$$RES
' Will return "01-91-1601"
DTV.01.01.1601|$$RES
MBX.$$RES
' Will return "1"
What is the difference between a date and a value?
A date is this: "01.01.2010".
A value is this: "149386".
What does VTD. do?
VTD. is the counterpart to DTV. It will convert a value back to a date.
DTV. delivers you the value for a date. That is the number of the given day,
counted from January 1601, one for each day.
For example, you will get a "149385" as value for the "01.01.2010" and
a "149386" as value for the "02.01.2010", which is one day later.
What do i do with these values?
Values that represent a date, are more easy to handle. Store them in files, do calculations with them. A date is just a number with DTV. Of course you can also add or subtract days from this value.
Can i convert that number back to a date?
Yes, finally you can convert that value back to a valid date using VTD. (Value to Date).
See DTV. - Date to Value on how to convert a date into a corresponding number.
Once you have such a number, VTD. will convert it back to a date. If you want to change the format of the given date, use DTC.
Here is an example, how
- a date is been converted into a number
- one day is added
- and then the number is converted back to the date..
$$DAT=12.12.2012
DTV.$$DAT|$$TIM
VIC.$$TIM
VTD.$$TIM
MBX.$$TIM
ENR.
' This example uses a given date-number "123456!
$$TIM=123456
VTD.$$TIM
MBX.$$TIM
Which will evaluate to the below result (picture below).
Of course you can also use 2 variables, in that case you get the same result.
$$TIM=123456
VTD.$$TIM|$$RES
MBX.$$RES
ENR.
Important:
You can use this date immediately for DTC. to convert it to any format you like.
Like this:
$$TIM=123456
VTD.$$TIM|$$RES
' change the date-format to anything you want.
DTC.$$RES|mm/dd/yy
MBX.$$RES
ENR.
Syntax
VTD.P1[|P2]
Parameter Explanation
P1 - Variable or number that should be converted to a date.
If you specify an variable in P1, and P2 is omitted,
then the result will be placed in that variable P1.
P2 - (optional) If specified, this variable will be used for the
resulting value.
Example
'**********************************************
' VTD. - Sample
'**********************************************
'
$$TIM=123456
VTD.$$TIM|$$RES
DTC.$$RES|dd+mm+yy
MBX.$$RES
ENR.
Remarks
-
Limitations:
All Date-calculations should be accurate up to a Millisecond back until 1601.
You can not specify negative values, therefore earlier dates then 1601 can not be calculated using VTD./DTV..
See also:
• DAT. - Date and Time Information (System independent)
• DTC. - Date and Time Calculation
• IDC. / NDC. - If Date Command
• CAL. - mathematical CALculation