Is there a way to add or substract minutes, hours, seconds, etc, to the current {DateTime}?
For example:
(current datetime) - (45 minutes) = datetime 45 minutes ago
(current datetime) - (1 hour and 5 minutes) = datetime 1 hour and 5 minutes ago
Or substracting any datetime to another datetime?
For example:
(datetime1) - (datetime2) = time elapsed
Thank you!
date_time difference
Re: date_time difference
You can do this with VB Evaluate action.
Look at my example below:
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Look at my example below:
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|397884660
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task67"
Hide=INTEGER|0
ID=INTEGER|1981151426
LogOnAsUser=INTEGER|1
Name=STRING|"date-time subtracting"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""DT1"" with value ""{DateTime}"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"DT1"
varvalue=STRING|"{DateTime}"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""DT2"" with value ""00:45:10"""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"DT2"
varvalue=STRING|"00:45:10"
[Actions\Action3]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate (dt1-dt2)"
Params=FOLDER
[Actions\Action3\Params]
expression=STRING|"datesubtract(""{dt1}"", ""{dt2}"")"
line00000000=STRING|"function DateSubtract(d1, d2)"
line00000001=STRING|" 'd1 and d2 are strings"
line00000002=STRING|" dt1 = cdate(d1)"
line00000003=STRING|" dt2 = cdate(d2)"
line00000005=STRING|" 'convert the result back to string"
line00000006=STRING|" DateSubtract = cstr(cdate(dt1-dt2))"
line00000007=STRING|"end function"
line00000009=STRING|"'aaa = DateSubtract(""12.02.2016 10:41:00"", ""00:45:10"")"
line0000000A=STRING|"'logmessage(aaa)"
linecount=STRING|"11"
loadfromfile=STRING|"1"
variable=STRING|"dt3"
[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""date-time1 = {dt1}"""
Params=FOLDER
[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"date-time1 = {dt1}"
msg1=STRING|"date-time2 = {dt2}"
msg2=STRING|"-----------------------"
msg3=STRING|"result = {dt3}"
msgcount=STRING|"4"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Re: date_time difference
This is great! Is there a web where I can see a list of those VB functions?
Thank you!
Thank you!
Re: date_time difference
This link is in the RoboTask's help file
Read about VB script language here: https://msdn.microsoft.com/en-us/library/t0aew7h6(v=vs.84).aspx
The same information is in online help here: http://robotask.com/help/index.php?vb_script.htm
For javascript see here: http://robotask.com/help/index.php?js_script.htm
Read about VB script language here: https://msdn.microsoft.com/en-us/library/t0aew7h6(v=vs.84).aspx
The same information is in online help here: http://robotask.com/help/index.php?vb_script.htm
For javascript see here: http://robotask.com/help/index.php?js_script.htm
Oleg Yershov