update query

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

Guest

i have column in which by mistake user had entered year as 1900i.e.
1901,1905.1906 instead of 2000i.e.2001,2003,2005. i want to change 19TH to
20TH century is ther any way to do that.
 
If the field holds only the Year and its a number type then you can use that
UPDATE TableName SET TableName.FieldName = [FieldName]+100

If the Field is a date type, then you can use that
UPDATE TableName SET TableName.FieldName = DateAdd("yyyy",100,[FieldName])

In both queries we add 100 years to the previeus field
 
One caution, I would use a WHERE clause to ensure that I was only updating
the values that are in the 1900-1999 range.

UPDATE TableName
Set TableName.YearField = TableName.YearField +100
WHERE TableName.YearField Between 1900 and 1999

or if a date field is involved then

UPDATE TableName
Set TableName.DateField = DateAdd("yyyy",100, TableName.DateField )
WHERE TableName.DateField >= #1/1//1900# and TableName.DateField <
#1/1/2000#

As always, test this on a copy of your data. There is no way to go back if
you don't have a backup of the database.

Ofer said:
If the field holds only the Year and its a number type then you can use
that
UPDATE TableName SET TableName.FieldName = [FieldName]+100

If the Field is a date type, then you can use that
UPDATE TableName SET TableName.FieldName = DateAdd("yyyy",100,[FieldName])

In both queries we add 100 years to the previeus field
--
If I answered your question, please mark it as an answer. That way, it
will
stay saved for a longer time, so other can benifit from it.

Good luck



prac g said:
i have column in which by mistake user had entered year as 1900i.e.
1901,1905.1906 instead of 2000i.e.2001,2003,2005. i want to change 19TH
to
20TH century is ther any way to do that.
 
Back
Top