4 Replies Latest reply: May 15, 2014 10:09 AM by Grant Perkins RSS

    How do I convert date from "MM/DD/YY" to  "MM/YY"

    twilliams _

      I've been trying to convert my date to display just the Month and the Year. 

       

      For example my report includes the day "12/1/2010" but I don't want the day to display in my output.  I want it to display the date as "12/2010" or "12/10".

       

      Thanks for your help

      Tracy

        • How do I convert date from "MM/DD/YY" to  "MM/YY"
          Olly Bond

          Hello Tracy,

           

          If your field is of the type "Date/Time" then you should be able to configure the display if the data by adjusting the Regional Settings in the Windows Control Panel.

           

          If that's not practical (as it would affect other programs), the you can use the dtoc() function to convert the date to a character string, and then all the useful text functions like extract(), substr(), left() etc should help you get what you need.

           

          Best wishes,

           

          Olly

            • How do I convert date from "MM/DD/YY" to  "MM/YY"
              Grant Perkins

              Tracy,

               

              Assuming the source field is a date field have you looked at using the MONTH() and YEAR() functions?

               

              A calculated field using the concatenation of those two functions should give what you want .

               

              STR(MONTH(input_date))"/"STR(YEAR(input_date))

               

              For a 2 character year rather than 4 character year .....

               

              STR(MONTH(input_date))"/"STR(RIGHT(YEAR(input_date),2))

               

              HOWEVER - if you always want the month to be 2 characters (01 through 12) and a 2 character year to display as "08", "09", etc. you will need to specify that as part of the STR function. It's covered in the Help file so maybe no point in repeating it here at length. It's easy enough to do when you see the examples.

               

              If the date is not a date field you may neet to 'convert' it first using the CtoD() function.

               

              Does this move things forward for you?

               

              If the data format is not a date as recognised by your Regional Settings then the approaches suggested by Olly above are the way to go.

              HTH.

               

               

              Grant