Hi All,
I am getting the date as decimal in my source like 2007001.In this 2007 is the year and 001 is the day of the year...and i want to get the date from that.I want my output as 2007-01-01.can somebody help me out how to get this.
Thanks in advance....
Regards,
skumar.
Decimal to Date Conversion
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You have the year and the ordinal number of the day in the year. You can extract these components with arithmetic operations/functions. Divide by 1000 to get the year, take the remainder (Mod() function) to get the day.
Then you can use date conversion functions to generate a Date from those components.
Format does not come into it unless you require a string to be generated. In that case, use another conversion function to convert the date into a string.
Then you can use date conversion functions to generate a Date from those components.
Format does not come into it unless you require a string to be generated. In that case, use another conversion function to convert the date into a string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Re: Decimal to Date Conversion
Hi,
I feel you need to change the logic that Ray said, a little bit. Get the year and ordinal number of the day in the year according to Ray. Then u need to subtract one day from the ordinal number of the day calculated above and then use DateFromDaysSince function. Like, if value comes from src is 2007002, u will get year as 2007 and day as 2. use 2007-01-01 and 1 (i.e 2-1) as the argument of that function then u will get the correct result (i.e 2007-01-02).
I feel you need to change the logic that Ray said, a little bit. Get the year and ordinal number of the day in the year according to Ray. Then u need to subtract one day from the ordinal number of the day calculated above and then use DateFromDaysSince function. Like, if value comes from src is 2007002, u will get year as 2007 and day as 2. use 2007-01-01 and 1 (i.e 2-1) as the argument of that function then u will get the correct result (i.e 2007-01-02).
skumar wrote:Hi All,
I am getting the date as decimal in my source like 2007001.In this 2007 is the year and 001 is the day of the year...and i want to get the date from that.I want my output as 2007-01-01.can somebody help me out how to get this.
Thanks in advance....
Regards,
skumar.
Altis Consulting Pty Ltd
www.altis.com.au
www.altis.com.au
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Do you purport to represent Altis? If not, please choose a different nick.
If so, please endeavour to use a professional standard of written English: the second person personal pronoun is spelled "you". DSXchange is not a mobile phone. Sentences ought really not to begin with "Like, ".
If so, please endeavour to use a professional standard of written English: the second person personal pronoun is spelled "you". DSXchange is not a mobile phone. Sentences ought really not to begin with "Like, ".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.