ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Format date to MM/DD/YYYY

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

  • #16
    Re: Format date to MM/DD/YYYY

    Hi,

    I'm doing a select mydate from whereever and dates are displayed as YYYY-MM-DD
    Before you try all these more or less complicated solutions you already got, just a question. Where or how do you want to display dates?

    If you are using interactive SQL (STRSQL), just do the following steps:
    • Press F13=Services
    • Select 1. Change Session Attributes
    • Change the date format from *ISO to *EUR


    If you are working with iSeries Navigator's Run an SQL Script:
    • Click Connection
    • Click JDBC-Setup
    • Click Format
    • Change the date format to the format you want


    Other interfaces may have comparable possibilites to change the date format.
    A date is always stored as 4 byte binary value repesenting the calculated days from 01/01/0001. A date format is used to make this cryptic date readable.

    But the date separators for the predefined date formats ISO, USA, EUR and JIS are fixed and cannot be changed.
    ISO: YYYY-MM-DD
    USA: MM/DD/YYYY
    EUR: DD.MM.YYYY
    JIS: YYYY-MM-DD

    I you really need to show the European date with slashes as separators, you have to convert the date into the character representation of the date and replace the date separators after:
    PHP Code:
    select translate(char(current_dateEUR), '/''.')
       
    from sysIbm/sysdummy1
    Birgitta

    Comment


    • #17
      Re: Format date to MM/DD/YYYY

      NOW THAT IS AN ANSWER!

      so smart that birgitta
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #18
        Re: Format date to MM/DD/YYYY

        Here is a different wrinkle. I have an 8 digit number containing a date in YYYYMMDD format. Anyway to read that number in (using SQL) and reformat it into a 6 digit number in MMDDYY format?

        I am digging through the manual right now, but was hoping someone had a quick answer.

        Comment


        • #19
          Re: Format date to MM/DD/YYYY

          This isnt exactly what you asking but it will get you in the right field..

          PHP Code:
          Select OhNum,
             
          SubstrDigitsOhDtOr ), 1)|| '-' || 
             
          SubstrDigitsOhDtOr ), 5)|| '-' || 
             
          SubstrDigitsOhDtOr ), 7
             As 
          OrderDate
             
          DateSubstrDigitsOhDtOr ), 1
              || 
          '-' || 
                
          SubstrDigitsOhDtOr ), 5
                 || 
          '-' || 
                
          SubstrDigitsOhDtOr ), 7) ) 
             + 
          10 Days As EstShipDate 
            From OrdHdr 
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #20
            Re: Format date to MM/DD/YYYY

            "right field"?!? But I want to play in center field!

            "Time passes, but sometimes it beats the <crap> out of you as it goes."

            Comment


            • #21
              Re: Format date to MM/DD/YYYY

              There are times like this that we're just happy he's in the RIGHT BALLPARK!

              Comment


              • #22
                Re: Format date to MM/DD/YYYY

                have i told you how much I like cheese ?

                I guess Ill save that for another day!


                happy weekend ALL

                jamie
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment

                Working...
                X