Page 1 of 1

Date Conversion

Posted: Tue Mar 06, 2007 5:25 am
by bucks
Hi,
I need convert a date format which is year and a day ex:-2007045 to a format 2007-02-14.

can anyone help me regading this?

Thanks !

Posted: Tue Mar 06, 2007 5:49 am
by kumar_s
Hi and Welcome to Dsxchange :D !!!!!

Try using

Code: Select all

StingToDate(Input.field, "%YYYY%DDD")

Re: Date Conversion

Posted: Tue Mar 06, 2007 7:01 am
by Mohanram
HI ,
Try it using iconv and Oconv function..
ex:if the date is 2007032 which represents 2007-02-01
use the below mentioned function in the transformation stage


OCONV(ICONV('2007032','DYD[4,3]'),'D-YMD[4,2,2]')

Posted: Tue Mar 06, 2007 7:49 am
by DSguru2B
The input looks like Julian date to me. Try

Code: Select all

DateFromJulianDay(in.Date)
ICONV/OCONV is not present in parallel jobs unless you use a basic transformer.

Posted: Tue Mar 06, 2007 7:57 am
by chulett
Technically, that's actually an 'Ordinal' date - the year followed by the number of the day within that year. However, from what I recall, that DateFromJulianDay function is actually expecting an Ordinal date. :?

Posted: Tue Mar 06, 2007 8:00 am
by DSguru2B
Your right Craig. Somehow 'they' got the naming wrong for the function.

Posted: Tue Mar 06, 2007 8:54 am
by bucks
Thanks kumar and for all the replies,

I have used lengthy procedure for this conversion using function DateFromDaysSince(), using stage var.


Funny thing is, it worked with simple StringToDate(datefield,"%yyyy%ddd").


:lol:

Re: Date Conversion

Posted: Tue Mar 06, 2007 5:27 pm
by kumar_s
Hi Mohan,

Iconv/Oconv are BASIC function used in Server jobs, and Basic Transformer in PX jobs which are seldom used.

Posted: Tue Mar 06, 2007 5:28 pm
by kumar_s
bucks wrote:Thanks kumar and for all the replies,

I have used lengthy procedure for this conversion using function DateFromDaysSince(), using stage var.


Funny thing is, it worked with simple StringToDate(datefield,"%yyyy%ddd").


:lol:
Do you mind marking the post as resolved.