Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: NTP YMDHMS TIME NTP2YMDHMS TIMESTAMP
#DefineFunction NTP2YMDHMS(NTPTime,mode) ;Base function courtesy of Les Ferch ;This udf converts data collected in NTP format ;making it suitable for either date manipulation with native ;Winbatch functions, i.e. TimeDiffSecs() ;or inserted directly as a timestamp into databases ;such as Access or SQL Server ;example NTP Format: 07:46:30.024 EST Fri Jan 30 2009 ;This udf does not take the TimeZone into consideration ;for conversion, but that could be easily added ;Parameters: NTPTime string in NTP format [see above] ; mode how conversion data is returned NTPTime = StrClean(NTPTime,".:"," ",@FALSE,1) Year = ItemExtract(9,NTPTime," ") MonthName = ItemExtract(7,NTPTime," ") Month = StrFixLeft( ((StrIndexNC("JanFebMarAprMayJunJulAugSepOctNovDec",MonthName,1,@FWDSCAN) + 2) / 3),"0",2) If StrLen(StrTrim(Month))==1 Then Month = "0":Month Day = StrFixLeft(ItemExtract(8,NTPTime," "),"0",2) If StrLen(StrTrim(Day))==1 Then Day = "0":Day Hour = ItemExtract(1,NTPTime," ") Minute = ItemExtract(2,NTPTime," ") Second = ItemExtract(3,NTPTime," ") If mode==1 Then Return Year:":":Month:":":Day:":":Hour:":":Minute:":":Second ;Winbatch Else Return Year:"-":Month:"-":Day:" ":Hour:":":Minute:":":Second ;DateTime Time Stamp EndIf #EndFunction
Article ID: W18402
Filename: Convert NTP to YMDHMS.txt
File Created: 2009:02:09:12:34:10
Last Updated: 2009:02:09:12:34:10