ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using SQL to compare yyyyddd to mmddyyyy

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

  • #16
    Thanks for the replies. Posting what I ended up doing once I remembered I was working with embedded SQL in an RPG program:


    exec sql
    select CURDAT info :#dateusa
    from datefile

    #datejul = %dec(%char(%date(#dateusa:*usa):*longjul0):9:0);

    This changes yyyymmdd to yyyyddd.

    Comment


    • #17
      That certainly changes things

      But for completeness:

      This thread already talks about timestamp_format(), that can date a date/time/timestamp string in a number of formats and convert to timestamp type.

      Ted Holt just posted a new Guru post on itjungle.com that talks about a similar function, varchar_format(), that does the opposite - takes a timestamp and converts it to a string in a number of formats. E.g. to convert timestamp to char in YYYYDDD Julian format:
      Code:
      varchar_format(record_timestamp_field,'YYYYDDD')
      Ted's post: https://www.itjungle.com/2018/03/26/...ons-using-sql/

      IBM doc on varchar_format(): https://www.ibm.com/support/knowledg...charformat.htm

      Comment

      Working...
      X