Changing date in number format to dd/mm/yyyy?

G

Guest

The database I use stores dates as numbers in the form yyyymmdd. Is there an
easy way to convert that to a date format, mm/dd/yyyy? Thanks.
 
G

Guest

if the date is split between 3 fields (month/day/year) you can create a date
with DATESERIAL(YearValue,MonthValue,DayValue), if it's a string that looks
like a date, if it's in a format that Access recognizes you can use
CDate(Value to Convert).
 
D

Douglas J Steele

CDate(Format(MyNumber, "0000-00-00"))

That will convert the number to a date, which will be displayed in whatever
format you've set as your default under Regional Settings in the Control
Panel.

If you want to force the display to be mm/dd/yyyy, regardless of what the
Short Date format has been set to in Regional Settings, use

Format(CDate(Format(MyNumber, "0000-00-00")), "mm\/dd\/yyyy")

Note that using the Format function will actually convert the date into a
string.
 
G

Guest

I have the same issue, but I have tried this along with the CVDate
recommendations and neither one works...I keep getting a data type mismatch
error. Does the original value have to be text for this to work (my value is
numeric yyyymmdd). PLEASE HELP!!!!!!!

Eric
 
J

John Vinson

I have the same issue, but I have tried this along with the CVDate
recommendations and neither one works...I keep getting a data type mismatch
error. Does the original value have to be text for this to work (my value is
numeric yyyymmdd). PLEASE HELP!!!!!!!

CVdate cannot handle a bare six-digit number to a date. It needs the
slashes, or dashes, or some sort of punctuation to make it look like a
date. Try

CVDate(Format([numberdate], "@@@@/@@/@@"))


John W. Vinson[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