How can I get a UTC timestamp in SQL400 on iSeries?

kratenko

Our iSeries (aka AS400, aka i5, aka SystemI) runs in local time, but we have an application, that uses UTC (written in Java, connected by JDBC to the iSeries DB).

How can I generate UTC-timestamps via SQL on that system?

kratenko

DB2/400 (which likes to be different in details from other DB2 flavours), has a special register called CURRENT TIMEZONE. It contains a numeric value, that can be subtracted from a timestamp or time value.

In an example query:

SELECT 
    CURRENT TIMESTAMP AS local, 
    CURRENT TIMEZONE AS offset, 
    CURRENT TIMESTAMP - CURRENT TIMEZONE AS utc
FROM SYSIBM.SYSDUMMY1

Gives you something like:

+----------------------------+--------+----------------------------+
| LOCAL                      | OFFSET | UTC                        |
+----------------------------+--------+----------------------------+
| 2014-05-27 14:09:19.127339 | 20.000 | 2014-05-27 12:09:19.127339 |
+----------------------------+--------+----------------------------+

Notes:

  • This example has an offset of +2 hours for central European summer time.
  • SYSIBM.SYSDUMMY1 is a special table supplied by IBM, with the sole purpose of having exactly one row with exactly one column.
  • Things like NOW() - CURRENT TIMEZONE and CURRENT TIME - CURRENT TIMEZONE work as well.
  • Reference in IBM's iSeries information center

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How can i get the fileinfo of all files in a folder with GetFile()?

来自分类Dev

How can I get around this annoying WiX issue?

来自分类Dev

How can I get a list of PHP errors occurred in a page?

来自分类Dev

How can i get a single widget(li) JSON in gridster?

来自分类Dev

How can I get last inserted id using Hibernate

来自分类Dev

How can I get the original resource in ngResource with a responseError interceptor?

来自分类Dev

How can I get the Mercurial Changeset ID from a revision number?

来自分类Dev

如何在iSeries上的SQL400中获得UTC时间戳?

来自分类Dev

How can I get path to current twig template dynamically?

来自分类Dev

使用Iseries SQL拆分列

来自分类Dev

How can I get list of users of a specific domain?

来自分类Dev

How can I get the application path in C?

来自分类Dev

How can I get the current weekday in Rust using the Chrono crate?

来自分类Dev

将RPGLE从GitHub集成到iSeries(IBM i)

来自分类Dev

AS400 iSeries客户端访问多个版本

来自分类Dev

How can I *only* get the number of bytes available on a disk in bash?

来自分类Dev

这是从日期获取UTC处的java.sql.Timestamp的正确方法吗?

来自分类Dev

SQL查询-db2 / 400 iseries

来自分类Dev

How can I get 3D object dimensions in ThreeJS?

来自分类Dev

How can I get this Django template to render?

来自分类Dev

How can i get the value of a variable through the Super keyword?

来自分类Dev

How can I get a detailed log of django csrf failure?

来自分类Dev

在IBM i(AS / 400,iSeries)上创建播放进化表

来自分类Dev

How can I get the amount of available memory portably across distributions?

来自分类Dev

IBM DB2 for i SQL(iSeries)-使用更新从字段末尾除去字符

来自分类Dev

如何使用Cwbx.dll和AS400System类从C#到IBM i(iSeries)设置库列表

来自分类Dev

SQL查询-db2 / 400 iseries

来自分类Dev

IBM AS400 iSeries - select 语句的排序顺序

来自分类Dev

在 iSeries/AS400 上运行 jprofiler 的问题

Related 相关文章

  1. 1

    How can i get the fileinfo of all files in a folder with GetFile()?

  2. 2

    How can I get around this annoying WiX issue?

  3. 3

    How can I get a list of PHP errors occurred in a page?

  4. 4

    How can i get a single widget(li) JSON in gridster?

  5. 5

    How can I get last inserted id using Hibernate

  6. 6

    How can I get the original resource in ngResource with a responseError interceptor?

  7. 7

    How can I get the Mercurial Changeset ID from a revision number?

  8. 8

    如何在iSeries上的SQL400中获得UTC时间戳?

  9. 9

    How can I get path to current twig template dynamically?

  10. 10

    使用Iseries SQL拆分列

  11. 11

    How can I get list of users of a specific domain?

  12. 12

    How can I get the application path in C?

  13. 13

    How can I get the current weekday in Rust using the Chrono crate?

  14. 14

    将RPGLE从GitHub集成到iSeries(IBM i)

  15. 15

    AS400 iSeries客户端访问多个版本

  16. 16

    How can I *only* get the number of bytes available on a disk in bash?

  17. 17

    这是从日期获取UTC处的java.sql.Timestamp的正确方法吗?

  18. 18

    SQL查询-db2 / 400 iseries

  19. 19

    How can I get 3D object dimensions in ThreeJS?

  20. 20

    How can I get this Django template to render?

  21. 21

    How can i get the value of a variable through the Super keyword?

  22. 22

    How can I get a detailed log of django csrf failure?

  23. 23

    在IBM i(AS / 400,iSeries)上创建播放进化表

  24. 24

    How can I get the amount of available memory portably across distributions?

  25. 25

    IBM DB2 for i SQL(iSeries)-使用更新从字段末尾除去字符

  26. 26

    如何使用Cwbx.dll和AS400System类从C#到IBM i(iSeries)设置库列表

  27. 27

    SQL查询-db2 / 400 iseries

  28. 28

    IBM AS400 iSeries - select 语句的排序顺序

  29. 29

    在 iSeries/AS400 上运行 jprofiler 的问题

热门标签

归档