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.

Comments

  1. Hey Aldo , there is a another issue solution provided by DB2 the example includes timezone as well if needed

    values (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

    ReplyDelete
  2. wToday = %dec(%char(%date():*ymd0):6:0); // today - oggi
    You can change %dec for %int as well making it shorter

    wToday = %int(%char(%date():*ymd0)); // today - oggi

    ReplyDelete
    Replies
    1. Yes, it's true. It also works with %int. Thank you my dear reader.

      Delete

Post a Comment

Popular posts from this blog

IBMi (AS400) fans only ‘ Memories (IBM Coding Forms)

IBMi (AS400) fans only ' SQLCODE values: Dear readers, unleash your suggestions!

Efficient WRKSPLF with WSF: How to Search string into spooled files, Sort, and Generate PDFs on IBMi