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…!!!

About Me!!

Hello Friends,

Programming is fun (Not for everybody but at least for people like me). 

Hey Guyz this is Yusuf, who is working as Software developer from past 6 years. I have been working under As/400 IBM i (RPGLE, DB2) technology and HTML5, JavaScript some times Ruby. In this on going journey I have failed/succeeded/learnt a lot. I would like to share the interesting things which I have come across to the world via this blog and I hope it may save some of your valuable time. 

Have fun!!! Happy coding...!!!!

Thanks & Regards,
Mohammed Yusuf