Sunday, March 19, 2017

Time Zone component in AS400


Hello Friends,

Have you come across a scenario on which your AS400 system (IBM i) may need to communicate with other system (those are in different time zone) and you needed to interface any date (or) timestamp value which eventually require time zone component added to it?

Actually I did come across this situation and I was searching for a clean method for time zone conversion in AS400. This should have the capability of converting time zone from one another considering Day Light Saving (DST). Interesting right?

Luckily AS400 is providing a “Convert Date and Time Format” (QWCCVTDT) API to do the same.


So how does it work?


DSPSYSVAL  SYSVAL(QTIMZON) → Use this command to see your system time zone



We can see here time zone is QP0100CET4. What does it mean? If you check with WRKOBJ command we can see it is a time zone component. To understand more on it use below command.

WRKTIMZON →   This will list all time zone component you have in your system.



Wow!! We have time zone description including day light saving time shift as well. That s great.


How to use this in our QWCCVTDT API?


Basically this API has 3 main parameter Input_TimeStamp, From Time Zone & To Time Zone.

From & To time zone parameters are time zone components (like QP0100CET4). I have written a small utility program which will convert time zone & also return time zone abbreviation value for the converted time zone. Click here to view the code.

Note: AS400 itself is not coming with all list of Time Zone component installed. But we have a provision to create our own by CRTTIMZON command. We can give our own offset values (like UTC+5) and define our DST timing as well.

Hope you will find this helpful if you are searching a solution for time zone conversion in AS400.

Have Fun!!! Happy Coding…!!!

3 comments:

  1. I like your bold viewpoints on this subject. I can tell you have a passion for writing. You are simply amazing! I have never read articles on this subject matter that made so much sense. Your points are right on and solid as a rock! Thank you. time zone converter

    ReplyDelete
  2. That's an interesting article. Thank you for sharing this knowledge.

    ReplyDelete
  3. HI Yusuf
    Your videos are helping me a lot,
    can u please make video on prevent duplicate values in sub files,
    Could you show me the total program RPGLE and the total DSPF please?

    ReplyDelete