date conversion from m/d/yyyy to yyyymmdd

J

jeff

I have a cell with a custom date format of m/d/yyyy h:mm,
I need to convert the date to yyyymmdd text. Does anyone
have a VB macro code snippet to do something like this?
I've tried text to columns but can't get it to work...any
help is appreciated.

Thanks.
 
P

Patrick Molloy

You aren't clear. Does the cell CONTAIN as date or is it
just the format that you want to change?
Try changing the format to General. If its a 'date' you
will see the cell value as a number like 36752. If you
still see a text date, then the cell is text.
You could convert to a date using the DateValue()
function.
Now all you need to do is formatthe cell yyyymmdd

if you need the text in a cell
=TEXT(DateValue(A1),"YYYYMMDD")
where A1 is your text date

HTh
Patrick Molloy
Microsoft Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top