Page 1 of 1

pgDateFormat

PostPosted: Fri Feb 20, 2015 3:31 pm
by John Robin Dove
Hi Clifton,

I would like to format this "2015-02-20'T'16:01:00" to seconds. Is it a recognizable date string? It's from the pgDateFormat "isoDateTime" output mask. I want to return it to seconds or milliseconds so that I can compare it with the current date and time. So far I've only got an NaN error.

Update: This: var msec = Date.parse("2015-02-20T16:01:00") works here http://www.w3schools.com/js/tryit.asp?filename=tryjs_date_convert but I can't do with pgDateFormat. Maybe Ishould try exeJavascriptDirect?

Re: pgDateFormat

PostPosted: Sat Feb 21, 2015 4:55 am
by John Robin Dove
Managed to do this with exeJavaDirect.

local variable dateStr = "2015-02-20T16:01:00"
commandString parameter: "var msec = Date.parse('" & dateStr & "'); return msec;"

Image

Re: pgDateFormat

PostPosted: Sat Feb 21, 2015 5:57 am
by Clifton
Nice post!
pgDateFormat() was not really designed to go back to a milliseconds format by inputting a masked date. We will consider this modification to the function, but your workaround is perfectly fine.
exeJavascriptDirect() was included in the PowerPac to provide a bridge for unusual or complex tasks for which there is no function.

Re: pgDateFormat

PostPosted: Sun Feb 22, 2015 9:56 am
by Clifton
Latest PowerPac beta adds the functionality you described above to pgDateFormat(). It streamlines it to support UTC, etc. A few bug fixes too. You can download it HERE.