B4J Code Snippet Next Reports DateTime Handling

When datetimes are UTC on the server (as they should be), and in the Long type, trying to get the users local time report output was a problem.

Tried - sql.ExecNonQuery("SET @@session.time_zone := '"&Main.sesstz&"'") (" ie '-07:00'. Didn't work...

Tried
url = "jdbc:mysql://localhost:3306/harris?user=harris&password=1111111&useLegacyDatetimeCode=false&serverTimezone=America/Vancouver"
This actually ADDED 7 hours to the date - instead of subtracting????

What did work:

In the Next Reports query, I have passed the timezone offset from the users browser (tzo) .
Set the tzo as double type.

FROM_UNIXTIME((eventmast.sdate / 1000 ) + ${tzo} ) as SD,
FROM_UNIXTIME((eventmast.edate / 1000) + ${tzo} ) as ED,

In B4J, add the param to the list.
inputlist.add("tzo")
inputlist.add( DateTime.GetTimeZoneOffsetAt( qsd ) * 60 * 60 ) ' qsd is the user selected start date.
ie (-7 * 60 * 60 ) = -25200

DateTime.GetTimeZoneOffsetAt will also compensate for DST.

Thanks
 
Top