Convert numeric field to date

C

cchristensen

Hello, I have a field that is currently formatted as numeric, i.e. 20071129
and need Access to recognize it as date, i.e. 11/29/2007. Tried simply
changing the format in table design, but didn't work. I know this is
probably really simple . . . any suggestions?

Thx.
 
J

Jerry Whittle

In a query:

TheDate: CDate(Mid("20071129",5,2)& "/" & Right("20071129",2) & "/" &
Left("20071129",4))

Replace "20071129" with [TheFieldName]
 
D

Douglas J. Steele

Easier is

TheDate: CDate(Format([TheFieldName], "0000-00-00"))

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jerry Whittle said:
In a query:

TheDate: CDate(Mid("20071129",5,2)& "/" & Right("20071129",2) & "/" &
Left("20071129",4))

Replace "20071129" with [TheFieldName]
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

cchristensen said:
Hello, I have a field that is currently formatted as numeric, i.e.
20071129
and need Access to recognize it as date, i.e. 11/29/2007. Tried simply
changing the format in table design, but didn't work. I know this is
probably really simple . . . any suggestions?

Thx.
 
J

Jerry Whittle

Very nice. I'll have to remember that one.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Douglas J. Steele said:
Easier is

TheDate: CDate(Format([TheFieldName], "0000-00-00"))

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jerry Whittle said:
In a query:

TheDate: CDate(Mid("20071129",5,2)& "/" & Right("20071129",2) & "/" &
Left("20071129",4))

Replace "20071129" with [TheFieldName]
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

cchristensen said:
Hello, I have a field that is currently formatted as numeric, i.e.
20071129
and need Access to recognize it as date, i.e. 11/29/2007. Tried simply
changing the format in table design, but didn't work. I know this is
probably really simple . . . any suggestions?

Thx.
 

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