Page 1 of 1
Date Manipulation
Posted: Sat Feb 27, 2010 9:29 am
by ppp
I have input data which is numeric and stored in 4 different fields as follows.
Century : 20
Year : 9
Month : 1
Day : 5
This data has to be formatted to arrive at the date in the format
2009-01-05 or 2009-01-05-HH.MM.SS.NNNNNN
How can I achieve this?
Posted: Sat Feb 27, 2010 9:42 am
by chulett
What is your target? Database table? If so, what data type? I ask because of your "has to arrive in X format" statement, that won't be true for an actual Date field.
Posted: Sat Feb 27, 2010 10:45 am
by ppp
My target is a flat file and it is varchar.
Posted: Sat Feb 27, 2010 11:16 am
by anbu
Code: Select all
(Century*100 + Year) : '-' : right('00':Month,2) : '-' : right('00':Day,2)
Posted: Sat Feb 27, 2010 11:17 am
by chulett
OK, then just assemble the pieces. FullYear = (Century*100)+Year. Month and Day append a '0' when Len = 1. Cat together with your delimiter.
Posted: Sat Feb 27, 2010 11:18 am
by chulett
I was going to let them work out the gory details, but... there you go.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Sat Feb 27, 2010 2:49 pm
by ray.wurlod
Nobody, not even the OP, has addressed how the time component has to be created.
Posted: Sat Feb 27, 2010 3:05 pm
by chulett
I specifically left it off as it seemed to be optional and since there seemed to be no actual time component incoming...