Change a numeric field to a date

G

Guest

I have a field of type long integer storing numeric dates as yyyymmdd eg
20040901.

I want to display these as ddmmyyyy. Is there an easier way than what I
have done below?

DateSerial(Left([tbl_Discounts]![DATE_END],4),Left(Right([tbl_Discounts]![DATE_END],4),2),Right([tbl_Discounts]![DATE_END],2)

Bruce
 
D

Duane Hookom

Your expression is close to what I would suggest except:
DateSerial(Left([tbl_Discounts]![DATE_END],4),Mid([tbl_Discounts]![DATE_END]
,5,2),Right([tbl_Discounts]![DATE_END],2))
 
J

John Spencer (MVP)

I haven't timed the two, but you could also use

DateValue(Format(20040901,"@@@@-@@-@@"))

I'm not sure what either one will do with invalid values or nulls. I guess
testing would find that out.

Duane said:
Your expression is close to what I would suggest except:
DateSerial(Left([tbl_Discounts]![DATE_END],4),Mid([tbl_Discounts]![DATE_END]
,5,2),Right([tbl_Discounts]![DATE_END],2))

--
Duane Hookom
MS Access MVP

Bruce said:
I have a field of type long integer storing numeric dates as yyyymmdd eg
20040901.

I want to display these as ddmmyyyy. Is there an easier way than what I
have done below?

DateSerial(Left([tbl_Discounts]![DATE_END],4),Left(Right([tbl_Discounts]![DA
TE_END],4),2),Right([tbl_Discounts]![DATE_END],2)

Bruce
 

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

Similar Threads


Top