Date conversion
Posted: Tue Apr 29, 2008 8:06 am
I have a requirement where in i have to convert mmddyy date format into YYYYMMDD
for example the date would be 070307 the output should be 20070307,
if the date is 012975 the output should be 19750129.
I have to compare the last 2 charaters from input(yy) if it is greater than 10
it has to be appended by 1975 or else append it with 20 i.e 2007.
The input column datatype is Numeric(coming in from a cobol copy book) and output column is number.
I am using the below
If Right(Col1,2) >10 then
DateToString(StringToDate(Col1,"%mm%dd%yy"),"%yyyy%mm%dd") else DateToString(StringToDate(col1,"%mm%dd%2000yy"),"%yyyy%mm%dd")
But i see that the even when Right(Col1,2) is less than 10(07) it always shows 19070307,where
it should be 20070307.
Is my approach correct or is there a better way to do this.
Kindly shed light on this.
Thanks
for example the date would be 070307 the output should be 20070307,
if the date is 012975 the output should be 19750129.
I have to compare the last 2 charaters from input(yy) if it is greater than 10
it has to be appended by 1975 or else append it with 20 i.e 2007.
The input column datatype is Numeric(coming in from a cobol copy book) and output column is number.
I am using the below
If Right(Col1,2) >10 then
DateToString(StringToDate(Col1,"%mm%dd%yy"),"%yyyy%mm%dd") else DateToString(StringToDate(col1,"%mm%dd%2000yy"),"%yyyy%mm%dd")
But i see that the even when Right(Col1,2) is less than 10(07) it always shows 19070307,where
it should be 20070307.
Is my approach correct or is there a better way to do this.
Kindly shed light on this.
Thanks