D
Dado
I want to change only the year in date field of one table. I have tried with
update query but i don't have right function or expression.
update query but i don't have right function or expression.
I want to change only the year in date field of one table. I have tried with
update query but i don't have right function or expression.
John Spencer said:UPDATE yourTable
SET YourDate = DateSerial(2008,Month(YourDate), Day(YourDate))
WHERE YourDate between #2007-01-01# and #2007-12-31#
You didn't post how you wanted th]e year changed or what you wanted the
change limited to. So the above is one idea.
Another way to make the same change
UPDATE yourTable
SET YourDate = DateAdd("yyyy",1,YourDate)
WHERE YourDate between #2007-01-01# and #2007-12-31#
The first version would change the year of every record in the database to
2008 if you dropped the criteria.
The second version would add one year to every record in the database.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Dado said:I want to change only the year in date field of one table. I have tried
with
update query but i don't have right function or expression.
Example: I have this date 27/09/2017 in many racords. I want to leave 27/09
but I want to change the year in 2007. It is easier to change the year in
every record to 2007.
Thank you
John Spencer said:UPDATE yourTable
SET YourDate = DateSerial(2008,Month(YourDate), Day(YourDate))
WHERE YourDate between #2007-01-01# and #2007-12-31#
You didn't post how you wanted th]e year changed or what you wanted the
change limited to. So the above is one idea.
Another way to make the same change
UPDATE yourTable
SET YourDate = DateAdd("yyyy",1,YourDate)
WHERE YourDate between #2007-01-01# and #2007-12-31#
The first version would change the year of every record in the database to
2008 if you dropped the criteria.
The second version would add one year to every record in the database.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Dado said:I want to change only the year in date field of one table. I have tried
with
update query but i don't have right function or expression.