Saturday, December 4, 2010

Date-to-number-or-text-conversion

Today I faced one problem. I wanted to convert Date from dd/mm/yyyy date format to text dd/mm/yyyy format.

If the date is 1st ; then it should be converted into 01.

If the month is 4th ; then it should be converted into 04.

I had written following formula for conversion:-
It is assumed that B9 field DATE.

=CONCATENATE(IF(LEN(LEFT(DAY(B9),2)=1),
CONCATENATE("0",LEFT(DAY(B9),2)),LEFT(DAY(B9),2)),"/",
IF(LEN(LEFT(MONTH(B9),2)=1),CONCATENATE("0",LEFT(MONTH(B9),2)),
LEFT(MONTH(B9),2)),"/",YEAR(B9))

but; there is some alternative easy way to do this using Text function



~ Harshal

No comments:

Post a Comment