There are three columns of date information (month, day, year) in a table and I would like to create a new column in the table and combine those 3 columns into a the new column so that I can have a single formatted date. How can I do this? I know how to query this but I am trying to figure out how to copy this information to the original table. Thanks in advance.
2 Answers
If I understood well, you need to alter your table and add a datetime column You need to do something like this
UPDATE YourTable
SET DATECOLUMN = '#' & DAYCOLUMN & '/' & MONTHCOLUMN & '/' & YEARCOLUMN & '#'
It was the sintaxis in access if i remember it well.
Greetings.
2 Comments
user759935
I tried the following and I got the error "Microsift access didn't update 10 fields due to a type conversion failure":
update Autographs set full_date = '#' & day & '/' & month & '/' & year& '#';TheOtherTimDuncan
The type conversion errors are probably from some invalid day, month or year values in your fields that are causing an invalid date to be generated. Look for values like Day=30 and Month=2.
There are a number of way of managing such a data scrubbing exercise e.g.
CREATEa new table including a newNOT NULLcolumn and omitting the now-redundant columns,INSERT..SELECTinto the new table only the data you require, DROP the old table (you'll end up with a different table name which may not be a bad thing).ADDa new nullable column to the existing table (orNOT NULLif you have an appropriateDEFAULT),UPDATEthe new column, alter the column to make itNOT NULLthenDROPthe now-redundant columns.
DATESERIALfunction.