Updating year only portion of date/time field

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Is it possible to only update the year portion of a date/time field?
The current dates are entered as xx/xx/xxxx, e.g. 3/5/2004, 4/22/2004,
etc. All the years should read 2004, but a batch of them read 1998 (no
idea why, i didn't enter them).
I've tried code like:
UPDATE Mainwith1998 SET serv = #Left(serv, Len(serv) - 4 & '2004'#
but keep getting syntax errors, whether I run it in a query or as
code. Any ideas? Thanks.
 
Dates are stored as decimal numbers, not as "dates". To update the date to
2004 year:

UPDATE Mainwith1998 SET serv =
DateSerial(2004, Month([serv]), Day([serv]));
 
Thanks, that worked great! Never heard of DateSerial, or that dates
are stored as decimal types. What's the point of a date/time field
then?
 
For effectively storing dates and times! Which are meant to be "points in
time", not elapsed time.

All dates with or without times, and all times with or without dates, are
stored as decimal numbers, where the date is the integer
portino (the number of full days since midnight, December 30, 1899), and the
time is the fractional part (the fraction of a 24-hour day represented by
the time).
 
Back
Top