I am trying to pull the date from the day before "objDate =
DateAdd("d", -1, Date)" in standard time format, and I am wanting to
convert it into UTC time "dtmCurrentDate = "&objDate&" " then pass it
into a SQL command " "WHERE [Type]='error' AND
[TimeWritten]>'&dtmTargetDate&' ". The script works however it isn't
passing the date and coverting into UTC. Can someone please help me
with this? Below you will find my script.
Thanks,
Robnson
-----------------------------------------------------------------------------
dim Conn, objRS, objConn, strSQL, objDate, dtmTargetDate
objDate = DateAdd("d", -1, Date)
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colTimeZone = objSWbemServices.ExecQuery _
("SELECT * FROM Win32_TimeZone")
For Each objTimeZone in colTimeZone
strBias = objTimeZone.Bias
Next
dtmCurrentDate = "&objDate&"
dtmTargetDate = Year(dtmCurrentDate)
dtmMonth = Month(dtmCurrentDate)
If Len(dtmMonth) = 1 Then
dtmMonth = "0" & dtmMonth
End If
dtmTargetDate = dtmTargetDate & dtmMonth
dtmDay = Day(dtmCurrentDate)
If Len(dtmDay) = 1 Then
dtmDay = "0" & dtmDay
End If
dtmTargetDate = dtmTargetDate & dtmDay & "000000.000000"
dtmTargetDate = dtmTargetDate & Cstr(strBias)
Set Conn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
Conn.Open = "provider=sqloledb;data source=SCK-EAV-01;" & _
"user id=sa;password=justD0!t;" & _
"initial catalog=Eventlogs"
strSQL = "SELECT [ComputerName], [EventCode], [Message] " & _
"[SourceName], [TimeWritten], [Type] FROM [EventTable] " & _
"WHERE [Type]='error' AND [TimeWritten]>'&dtmTargetDate&' ORDER BY
[TimeWritten]"
objRS.Open strSQL, Conn, 0, 1 'adOpenForwardOnly, adLockReadOnly
objRS.MoveFirst
While Not objRS.EOF
WScript.Echo objRS("ComputerName") & objRS("EventCode") &
objRS("SourceName")
objRS.MoveNext
Wend
______________________________________________________________________