Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

how to calculate difference between two dates inc milliseconds

$
0
0
I am trying to find the difference between two dates inc milliseconds

ie so that I can record how long a script is taking

the vbscript is called from another program and is passed two date parameters in format "DD/MM/YYYY HH:MM:SS.FFF"

(fff = milliseconds)

(although this can be adjusted by the passing program)

HTML Code:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c echo. >NUL  | clip", 0, True

Dim Arg, var1, var2
Set Arg = WScript.Arguments

'Parameter1, begin with index0
var1 = Arg(0)

'Parameter2
var2 = Arg(1)

intDays = DateDiff("s", var1, var2)

rem Clear the objects at the end of your script.
set Arg = Nothing

rem Wscript.Echo intDays

rem Put it back to the clipboard
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oIn = oExec.stdIn

oIn.WriteLine intDays
oIn.Close


if I exclude the miliseconds then my script wroks, if i included milliseconds it errors with type mismatch error, regardless of the format I pass the value in

I have searched high and low on t'internet and found variois scripts taht deal with todays date etc, but none that recieve 2 date parameters

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>