2 Replies Latest reply: May 15, 2014 10:01 AM by Grant Perkins RSS

    CTOD Function

    lutzaccounting _

      I have a field that is a character field that I want to be a date.  The data is in mmm-yyyy. I would like to convert it to a date using CTOD but I cant get it right ...

        • CTOD Function
          Data Kruncher

          Hello, and welcome!

           

          To convert your field to a proper date with CtoD, you need the month, day and year.

           

          Embed a day in your date, like this:

          [SIZE=2]

          CtoD(Left(,3)"/01/"Right(,4),"m/d/y")

          /SIZE[/CODE]

           

          This will give you the first of the month. This is how I deal with my fiscal periods, because the final reports never show the day number anyway.

           

          HTH,

           

          Kruncher

          • CTOD Function
            Grant Perkins

            I have a field that is a character field that I want to be a date.  The data is in mmm-yyyy. I would like to convert it to a date using CTOD but I cant get it right ...[/quote]

             

            Hi and welcome to the forum.

             

            You will need to add a dd to make the string a date, assuming you can choose a dd to use.

             

            ctod("dd-"+)

             

            should work under normal circumstances.  dd would be a day in the month.

             

            So if dd was entered as 01 and mmm-yyyy existed as JUN-2008 the above formula would concatenate 01- with JUN-2008 giving 01-JUN-2008 as a string of text.

             

            CtoD will then convert that to a value that can be displayed in a field defined as date format.

             

            Is that what you need to achieve?

             

            HTH.

             

             

            Grant

             

             

             

            Edit: Or Kruncher's solution of course if you need the m/d/y format as a starting point ..   overlap postings! :rolleyes: