Date Math Again

Started by stanl, June 16, 2015, 07:09:23 AM

Previous topic - Next topic

stanl

I need to convert the WB TimeYmdHms()  Into a value with say 5 decimal places to query a MySQL table with timestamps so I can look for timestamps >= my WB time. I tried this (as the TimeDiffSecs is limited to a 60 year lookback)

Code (Winbatch) Select

Decimals(5)
t1=TimeYmdHms()
t2=TimeDiffDays(t1,"1899:12:30:00:00:00")
t3=TimeDiffSecs(t1,ObjectType("DATE",t2))

Message("",t2:@CRLF:t2:".":t3)


My t3 var is about 1 hour off when I put the value into Excel and format as a datetime.

I cannot use MYSQL syntax in this script.  I know this is a kludge.

td

COM Automation's date representation is a little more involved than gluing a couple of integers together.  Give the following a try:

Code (winbatch) Select
Decimals(5)
fDate = ObjectType("R8",ObjectType("DATE",TimeYmdHms()))
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

I like that, thanks. Saves me from my huge math kludge.

stanl

One more thing worth noting. I haven't worked with MySQL since 2005 and most of that code was based on the 2005 WB compiler. Truth be told 2005 is the basis for the majority of the ADO code I have written.

ObjectType() is truly (IMHO) one of the most important functions added to WB. Tony's on-liner only prompts me to dig deeper into what that function can do.

DAG_P6

More impressive, in some respects, is that your 2005 code probably worked with few changes in 2015. ;)
David A. Gray
You are more important than any technology.