Link to home
Start Free TrialLog in
Avatar of alam747
alam747

asked on

How to change the format of date

Hi,
If some one advise me how to change format of date, for example it the date is 20121101(Nov.1st 2012) I need to change the format as 11/01/2012 or if the date is 20121030(Oct.30th 2012) I need to change the format as 10/30/2012.

Please advise the VBA code for the above.

Thanks
Avatar of jerryb30
jerryb30
Flag of United States of America image

Format(YourDateValue, "mm/dd/yyyy")
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DateSerial(Left(dd, 4), Right(dd, 2), Mid(dd, 5, 2))

assuming variable name: dd
I was wrong for text.  And it would not work for samples given even as a date field.
IronSinta has answer.
Not for points:
To hold the '0' of 01 Nov
Format(DateSerial(Left([d],4),Mid([d],5,2),Right([d],2)),"mm/dd/yyyy") where [d] is date value string.
DateSerial wants year month day. Can't rearrange order, at least in my db.
Avatar of alam747
alam747

ASKER

It works, Thanks a lot..