I am trying to convert a date field (CYYMMDD) to the format MMDDYYYY
using an update query on Access 2000. The formula I am using is:
Format(DateSerial(Left([Invoice Date],3),Mid([Invoice
Date],4,2),Right([Invoice Date],2)))
This is not working, it will not detect the records currently formatted
as: CYYMMDD.
Any suggestions on how to fix this?
Mike
The first argument of the DateSerial function must be a complete year
- e.g. 2005, 1994, or the like. I'm not sure what's in your "C"
subfield but a three-byte substring will not return a four-digit year!
Also, you don't need the Format() function. DateSerial will return a
valid Date/Time value which your computer should display using its
current Windows date/time short date setting; if you really want to
store the reformatted date back into the text field, which I do NOT
recommend, you'll need to *specify* a format.
GUESSING here that C=9 means 20th century, C=0 21st, then try
Format(DateSerial(Switch(Left([Invoice Date], 1) = "9", "19",
Left([Invoice Date], 1]) = "0", "20") & Mid([Invoice Date], 2, 2),
Mid([InvoiceDate], 4, 2), Right([Invoice Date], 2)), "mmddyyyy")
Again, this will not store a Date/Time value but rather a String.
Consider instead adding a date/time value and updating it to the
DateSerial() expression; you can then format it for display any way
you like, even several different ways in a single report or form.
John W. Vinson[MVP]