If you have DateTime fields containing Greenwich Mean Time (GMT) values, but want them displayed as local DateTime values, Stonefield Query has a built-in way to help with this otherwise cumbersome task.

Use the following steps to have a field display a local time rather than GMT:

  • If you want to display both GMT and local time, create a calculated field. If not, specify an Output Expression for the field containing the GMT values.

  • In either case, enter an expression similar to the following for the Output Expression of either the calculated field or the original field:

      iif(empty(nvl(MyTable.MyField, {/:})), MyTable.MyField, ;
          MyTable.MyField - SQApplication.TimeZoneOffset)
    

    where MyTable.MyField is the table name and field name of the field containing GMT values. (The iif(empty(nvl(MyTable.MyField, {/:})), part of the expression deals with null values.) Turn on the Stonefield Query expression setting.

  • Since you probably want to display the time as well as the date, enter "D" for the Format setting. This tells Stonefield Query to suppress its normal behavior, which is to display only the date portion of a DateTime field.

  • If you wish, you can use SQApplication.TimeZoneDesc to display the time zone, such as in the About dialog with an About.Settings script.


© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic