- Aug
- 2,217
- 101
Here's a library function that uses the script command, the tcommand() interface, and VBScript, to determine the number of years (full and part) given a date by the user;
Example usage;
Note well that the passed date, in this case, November 1, 1960, can be passed in several formats.
That is, VBScript (usually) has the intelligence to determine the date format entered by the user.
Ref: DateDiff - VBScript
The DateDiff library function also saves the result in the _datediff environment variable, for use else where in TCC, either from the command line, or a .BTM
Joe
Code:
DateDiff {
@setlocal
@echo off
set dest=%temp\vb.vbs
set theDate=%1
if defined theDate (
::NEXT SENTENCE
) else (
set theDate=%_isodate
)
>%dest echo TakeCommand.tcommand("echo " + CStr(DateDiff("d", "%theDate", Now) / 365.25))
set _DateDiff=%@execstr[script %dest]
echo %_DateDiff
endlocal _DateDiff
}
Code:
e:\utils>datediff 11/1/1960
61.1498973305955
e:\utils>datediff 1960-11-1
61.1498973305955
e:\utils>datediff `November 1, 1960`
61.1498973305955
e:\utils>echo %_datediff
61.1498973305955
That is, VBScript (usually) has the intelligence to determine the date format entered by the user.
Ref: DateDiff - VBScript
The DateDiff library function also saves the result in the _datediff environment variable, for use else where in TCC, either from the command line, or a .BTM
Joe
Last edited: