How do I use DateSerial?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I linked a table to my database, but the the date field in the table does not
match the the data type I use in my database. I can not change the data type
in the linked table because it will effect other databases. So I tried
copying the link and then tried to change to data type to date/time. But
when I did that, it caused an error and erased that field in the records.
The format in the the text field is "yyyymmdd", and I need it to be
"mm/dd/yyyy". I read that DateSerial could fix my problem but I don't know
how to use this function. Could someone help me.
 
DateSerial expects 3 arguments: year, month and day (in that order)

You could use DateSerial(Left(TextDate, 4), Mid(TextDate, 5, 2),
Right(TextDate, 2)).

However, the following might be easier:

CDate(Format(TextDate, "####\-##\-##"))
 
Thanks Douglas,

It worked perfectly!!!

Douglas J. Steele said:
DateSerial expects 3 arguments: year, month and day (in that order)

You could use DateSerial(Left(TextDate, 4), Mid(TextDate, 5, 2),
Right(TextDate, 2)).

However, the following might be easier:

CDate(Format(TextDate, "####\-##\-##"))

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)





.
 
Back
Top