Use of CDate

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

I've imported an Excel table into Access 2003 and the date fiels has appeared
in my table as a serial number. I think that I have to use the CDate function
to correct this, but how and, more importantly, where do I use this fuction.

Thanks
 
If the data looks like 40037, which is 12 August 2009, then you can use
something like below in a query:

TheDate: CDate([TheDateField])

One problem with CDate is that it will bomb out if any record in the table
can't be evaluated as a date. For example a Null empty string will cause an
error. Therefore I use something like below to return a bogus 1/1/1950 if
there is a problem with the date field.

TheDate: IIf(IsDate([TheDateField]), CDate([TheDateField]), #1/1/1950#)
 
Many thanks, Jerry, just what I wanted.

Jerry Whittle said:
If the data looks like 40037, which is 12 August 2009, then you can use
something like below in a query:

TheDate: CDate([TheDateField])

One problem with CDate is that it will bomb out if any record in the table
can't be evaluated as a date. For example a Null empty string will cause an
error. Therefore I use something like below to return a bogus 1/1/1950 if
there is a problem with the date field.

TheDate: IIf(IsDate([TheDateField]), CDate([TheDateField]), #1/1/1950#)
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

Nigel said:
I've imported an Excel table into Access 2003 and the date fiels has appeared
in my table as a serial number. I think that I have to use the CDate function
to correct this, but how and, more importantly, where do I use this fuction.

Thanks
 
Back
Top