Page 1 of 1

Decimal to Date Conversion

Posted: Wed Feb 27, 2008 12:34 am
by skumar
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.

Posted: Wed Feb 27, 2008 1:30 am
by ray.wurlod
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.

Re: Decimal to Date Conversion

Posted: Wed Feb 27, 2008 2:49 am
by altis
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).

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.

Posted: Wed Feb 27, 2008 3:29 am
by ray.wurlod
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, ".