Your Products have been synced, click here to refresh
Sub Main d1 = cdbl(dateserial(2015, 2, 1)) d2 = cdbl(dateserial(2015, 3, 1)) MsgBox d2-d1 End Sub
Sub Main d1 = cdbl(dateserial(2016, 2, 1)) d2 = cdbl(dateserial(2016, 3, 1)) MsgBox d2-d1 End Sub
ASSIGN/V2=SYSTEMTIME("HH:mm:ss") ASSIGN/HOUR1=ELEMENT(1,":",V2) ASSIGN/MINUTE1=ELEMENT(2,":",V2) ASSIGN/SEC1=ELEMENT(3,":",V2)
ASSIGN/V4=SYSTEMTIME("HH:mm:ss") ASSIGN/HOUR2=ELEMENT(1,":",V4) ASSIGN/MINUTE2=ELEMENT(2,":",V4) ASSIGN/SEC2=ELEMENT(3,":",V4) IF/HOUR2<HOUR1 ASSIGN/HOUR2=HOUR2+24 END_IF/ ASSIGN/V5=(HOUR2-HOUR1)*3600+(MINUTE2-MINUTE1)*60+(SEC2-SEC1) COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO, "Time = "+V5+" seconds"
A datetime is in fact a double, with the date in the integer part and the time in the decimals. So, you just convert your dates to double and do the subtraction, and you will get the number of days (and fractions of days) between the two:
Sub Main d1 = cdbl(dateserial(2015, 2, 1)) d2 = cdbl(dateserial(2015, 3, 1)) MsgBox d2-d1 End Sub
gives the answer 28, while
Sub Main d1 = cdbl(dateserial(2016, 2, 1)) d2 = cdbl(dateserial(2016, 3, 1)) MsgBox d2-d1 End Sub
gives 29, so it seems leap years are also handled.
You can add a "runtime" output in the report header. I replaced the stats count block since I don't use it. All my reports tell me how long the execute time was on my program. It helps to be able to walk away and work on something else until the program finishes
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |