ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Day Number

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Day Number

    Hi,
    In a CL, how do I get the day number in the year?
    IE: today June 16 = day 167.

    Mike.
    Everyday's a school day, what grade are you in?

  • #2
    Not easy with CL.
    The easiest way would be to write a procedure in RPG or any other programming language (that will determine it for you) and call this procedure

    You want to do it solely with SQL may have a look at the following APIs:
    CEEDAYS - Convert a date into a lilian date (number of days since October, 15 1582) https://www.ibm.com/docs/api/v1/cont...is/CEEDAYS.htm
    CEEDATE - Convert a lilian date to a character format (Format DDD will return the day of the year) https://www.ibm.com/docs/api/v1/content/ssw_ibm_i_74/apis/CEEDATE.htm

    Birgitta

    Comment


    • #3
      Hi,

      You can use CVTDAT to convert your date to julian format then get the last three digits

      Code:
      pgm
      dcl &date *char 10
      dcl &datejul *char 5
      
      rtvjoba date(&date)
      cvtdat date(&date) tovar(&datejul) fromfmt(*job) tofmt(*jul) tosep(*none)
      
      sndpgmmsg msgid(cpf9897) msgf(qcpfmsg) msgdta(%sst(&datejul 3 3)) topgmq(*ext)
      
      endpgm
      Nicolas

      Comment


      • #4
        Originally posted by vazymimil View Post
        Hi,

        You can use CVTDAT to convert your date to julian format then get the last three digits

        Code:
        pgm
        dcl &date *char 10
        dcl &datejul *char 5
        
        rtvjoba date(&date)
        cvtdat date(&date) tovar(&datejul) fromfmt(*job) tofmt(*jul) tosep(*none)
        
        sndpgmmsg msgid(cpf9897) msgf(qcpfmsg) msgdta(%sst(&datejul 3 3)) topgmq(*ext)
        
        endpgm
        PERFECT!
        Did exactly what I was looking for.
        Thank you.
        Everyday's a school day, what grade are you in?

        Comment

        Working...
        X