[SOLVED] Converting a Date to Epoch Time and DATEDIF
Hi,
I am having the hardest time converting a date to epoch time. I even tried using datedif to get the difference in days so that I can just multiply it out to get seconds but the results I am getting are completely wrong.
My datedif code looks like this:
DATEDIF(19700101,20120423,'D').
Shouldn't that return me the differnce in days? But what it seems to be doing is just giving me the difference between the numbers. What could I be doing wrong here? I am probably missing something completely obvious.
If anyone can help me convert a date to epoch time or help me understand why my DATEDIF function isn't working. I would appreciate it.
Thanks ahead of time. -PrinceThis message has been edited. Last edited by: Prince Joseph,
Webfocus 8, All Outputs
April 23, 2012, 07:11 PM
Dan Satchell
Try putting single quotes around your dates so DATEDIF knows you are providing dates instead of numbers. If you use date-time values instead, you can use function HDIFF to calculate the number of seconds between the two values.
WebFOCUS 7.7.05
April 23, 2012, 09:42 PM
Prince Joseph
Thanks for the help. I'll definitely try this.
Webfocus 8, All Outputs
April 24, 2012, 04:55 AM
Wep5622
You're going to run into DST and time zone offset problems with that approach, as timestamps are based in UTC (no DST), while your local time zone probably does do DST and has an offset.
Apparently there's no way in WebFOCUS to calculate the offset you need, but it's possible to ask a database you're connecting to (doesn't even matter much which one).
It suffices to figure out the offset between a date in your local time zone (DST or not) and the same date in GMT.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
April 25, 2012, 10:42 AM
Prince Joseph
Thanks for the help guys. I was able to finally figure it out. We have a method in place to get the offset time.