Page 1 of 1

Date datatype conversion

Posted: Sun Nov 20, 2011 11:07 pm
by srai
Hi,

I reading from Oracle database and loading into sequecial file.

From Oracle source Date is coming as

21-03-11
15-04-00
16-11-81

and we need output as
21-03-2011
15-04-2000
16-11-1981

I am trying to function StringtoDate(Columnname,"%dd-%mm-%yyyy").
But its not getting converted in required format.
Please suggest if I am using wrong derivation.

Thanks.

Re: Date datatype conversion

Posted: Mon Nov 21, 2011 12:36 am
by sathishmca
Hi,

StringtoDate(Columnname,"%dd-%mm-%yyyy").
Here ,"%dd-%mm-%yyyy" should match with your source data. Just try that.

Thanks

Re: Date datatype conversion

Posted: Mon Nov 21, 2011 1:57 am
by srai
Hi,

Thanks for reply.

This means if my source data is like 21-03-11 then it should be
StringtoDate(Columnname,"%dd-%mm-%yy") and output will be as
21-03-2011.

Thanks,
Santosh

Posted: Mon Nov 21, 2011 2:27 am
by pandeesh
Hi,

Just try

Code: Select all

StringToDate(column,"%(d,s)-%(m,s)-%yy).
if the result is still not as exepected, then apply one more DateToString()

Re: Date datatype conversion

Posted: Mon Nov 21, 2011 7:24 am
by chulett
srai wrote:This means if my source data is like 21-03-11 then it should be StringtoDate(Columnname,"%dd-%mm-%yy") and output will be as 21-03-2011.
No, your output will be a date which has no external format. If you need another string then you'll need to enclose the result in a DateToString() function with the appropriate output mask.