IBMi (AS400) fans only : Fully Free RPG get Today's date with a single instruction
In this example, the wToday field is numeric 6 with 0 decimal places.
#IBMiSample
It should contain today's date in yymmdd format
dcl-s WToday zoned(6);
wToday = %dec(%char(%date():*ymd0):6:0); // today - oggi
I appreciate all the comments made on this blog.
Hey Aldo , there is a another issue solution provided by DB2 the example includes timezone as well if needed
ReplyDeletevalues (current_timestamp , (current_timestamp - current time zone) , dec(varchar_format((current_timestamp - current time zone), 'mmddyy'),6))
Please try that and let me know
Best
Diego
Hi Diego, this approach is very useful when dealing with timezone-specific data. I'll definitely give it a try and let you know how it works out.
DeleteAlso, I apologize for the tremendous delay in getting back to you. I appreciate your patience and understanding.
wToday = %dec(%char(%date():*ymd0):6:0); // today - oggi
ReplyDeleteYou can change %dec for %int as well making it shorter
wToday = %int(%char(%date():*ymd0)); // today - oggi
Yes, it's true. It also works with %int. Thank you my dear reader.
Delete