2 Replies Latest reply: May 15, 2014 9:51 AM by Grant Perkins RSS

    More on Date/Time

    Mike Urbonas

      (Note: I am reposting this for user "Michaeljul" - for some reason the original topic got corrupted. -- Mike U.)

       

      I have two character fields: Date - in this format YYYY-MM-DD, and Time in this format HH:MM:SS - I concatenated the two by making a calculated field DATE" "Time - and thought i could convert that into a date/time field using the CTOD function, but I can not - can anyone help me with a hint???

        • More on Date/Time
          michaeljul _

          Ok - after some thinking and trial on error, solved it myself: first converted the Character field TIME (which is in format HH:MM:SS - Military time) with function CharToSeconds(time) - format numeric - this turns e.g. 18:52:00 into 67920. Then converted this new numeric field (Time1) into characters like this: SecondsToChar(Time1) - THEN I concatenated this new field (Time2) with the character field DATE: date" "time2 - this new field DATETIMECHAR, I turned into a 'real' date/time field like this: Ctod(,"y/m/d","DT")..... A lot of steps, and can probably be done easier, but it works. Thanks to Mike for resending my garbled post

          • More on Date/Time
            Grant Perkins

            Michael,

             

            Apologies if I have missed something significant in your description but dates and times are of particular interest to me so I played around a little.

             

            You mention that the Date and Time fields are character fields. Could you reset them in the model as DATE and TIME fields rather than character? If so you can simply concatenate as DATE+TIME.

             

            If not and the fields have to be character fields, have a look at the result of

             

            ctod(DATE)+Ctod(TIME)

             

            with the output field defined as 'Short Date and Time' or 'Long Date and Time'.

             

            More interesting things;

             

            datetime1    will add one day to the date.

             

            datetime.5    will add 12 hours

             

            datetime(7/24) will add 7 hours

             

            Works with the Ctod version as well.

             

            Hope this is of interest.

             

            Grant

             

             

            Originally posted by michaeljul:

            Ok - after some thinking and trial on error, solved it myself: first converted the Character field TIME (which is in format HH:MM:SS - Military time) with function CharToSeconds(time) - format numeric - this turns e.g. 18:52:00 into 67920. Then converted this new numeric field (Time1) into characters like this: SecondsToChar(Time1) - THEN I concatenated this new field (Time2) with the character field DATE: date" "time2 - this new field DATETIMECHAR, I turned into a 'real' date/time field like this: Ctod(,"y/m/d","DT")..... A lot of steps, and can probably be done easier, but it works. Thanks to Mike for resending my garbled post /b[/quote]