Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 changing dates with an UPDATE query

Author  Topic 

Doctor Doom
Starting Member

12 Posts

Posted - 2004-04-01 : 09:57:31
Hi, friends,

I have a problem here with an UPDATE query in ms Access:
I have a column in a table with dates of this year (from 1 january until 31 december).
I want to change only the year of each cell.

1 january 2004-->1 january 2005
2 january 2004-->2 january 2005
3 january 2004-->3 january 2005
and so on.

In the UPDATE query, I put: Year([date_column])+1
This doesn't seem to work. Neither do other formulas.

I get the next:
28 june 1905
28 june 1905
28 june 1905
and so on

I don't know where Access gets this from. I also looked in the Help manual of Access for the right formulas for dates, but I couldn't find a useful thing.

Can anyone help?

Thanks in advance

samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2004-04-01 : 10:04:20
HTH..

Select dateadd('yyyy', 1, '01/01/2003')

- Sekar
Go to Top of Page

Doctor Doom
Starting Member

12 Posts

Posted - 2004-04-01 : 11:34:10
Hi, Sekar,

I've tried your code, but I always get a syntax error. I've looked for syntaxes on the Net, but I can't see anything wrong in the code a put: DateAdd('yyyy',1,'01/01/2004')

The cursor jumps always at the same place after the error message: right on the first comma: DateAdd('yyyy',1,'01/01/2004')

Do you know what I'm doing wrong here?
Go to Top of Page

Doctor Doom
Starting Member

12 Posts

Posted - 2004-04-01 : 11:57:48
I've got it now, Sekar.

I don't know why Access keeps playing with me...
The right syntax was:

dateadd('yyyy';2;'01/01/2003') instead of
dateadd('yyyy',2,'01/01/2003')

Very frustrating indeed, especially when all the tutorials on the Net use the first one.

Thanks again!
Go to Top of Page
   

- Advertisement -