How do I change data types in an update query

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

Guest

I have imported data as text into a table, I want to change one of the
columns to a date then to date format "MMM" - is this possible with an update
query?
 
Yes, it is possible. You will need to use Left, Right and Mid functions to
crop the text parts for year, month and day, a Val function on each so you
get a numerical value, and all of those combined in a DateSerial function to
get the actual date in date/time format. A format function on it will return
just the month part in the desired format for storing (in the same field, as
text). Here's an example, assuming the original diled is called fDate, and
its format is yyyy/mm/dd:

Format(DateSerial(Val(Left([fDate],4)),Val(Mid([fDate],4,2)),Val(Right([fDat
e],2)),"mmm")

(watch out for wrapping in the post, it's all in one line!).

HTH,
Nikos
 
Back
Top