–updated script to handle UTC (GMT) timezones.
/** SCRIPT: Get userfriendly timestamp for wmerror as column ts
FOR MS SQL SERVER
Author: Richard Bailey
NOTE: the - 05 in the query below represents the timezone.
change this value to correlate with the timezone your
database server resides in.
Also, the script will not work if you attempt to calculate
using milliseconds as MS SQL Server has limits to how large
the integer is for calculating milliseconds.
-you could do some additional math which you calculate the
date since the year 2000, then add 30 years… but this works
perfect for what we need it to do.
WHAT IT IS DOING?
-select all of the columns from wmerror table
-use the dateadd function to subtract - 05 hours (hh)
from the sub-dateadd value
-the sub-dateadd value is converting the millisecond
value from the audittimestamp value in to seconds (/1000)
then adding those seconds to 01/01/1970
**/
SELECT DATEADD(hh, - 05, DATEADD(ss, AUDITTIMESTAMP / 1000, ‘01/01/1970’)) AS ts, *
FROM WMERROR
____________script above this line
To make life easier on our team, I created SQL Server Views that run the script above for each of the tables (wmerror, wmsession, wmaudit, etc…) so that the team can simple run a query in analyzer or in their web pages that report the logs: something like “SELECT * FROM sqlview_wmerror WHERE ts BETWEEN ‘2003-10-14’ AND ‘2003-10-15’ ORDER BY ts”
Hope this helps someone.
#webMethods#Integration-Server-and-ESB#webMethods-General