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 in a table

Author  Topic 

Doctor Doom
Starting Member

12 Posts

Posted - 2004-05-28 : 05:32:36
Hi, friends,

I have an interesting problem here:
I have an MS Access-table with 366 rows and one column, whithin each row the date of one day in a year (from 1 januari 200x until 31 december 200x).
Also, I have a query that increases the days with on year. Another query decreases it (whith the formula DateAdd("yyyy",+/-1,[date]).

My problem is that irritating leap-year (you know: 29 februari)

So, when my table is filled whith dates of this year (366 rows),
and I click on the query to increase it to the next year (365 rows), I'm stucked with one row (29 februari).
It doesn't matter on which year the table is filled, there will always be a problem with one row when it comes to a leap-year.
Is there a genius in the house who can see a simple solution here to avoid an error message from MS Access?

Thanks in advance!

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-28 : 05:56:58
Why not just delete and repopulate the field when you want to change the year???
Go to Top of Page

Doctor Doom
Starting Member

12 Posts

Posted - 2004-05-28 : 06:04:52
I'm using now the formula "DateAdd("yyyy",+/-1,[date]".

When I have an empty table, which sql-instruction do I have to use to repopulate the table (for let's say the year 2007),RickD?
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-28 : 06:17:50
in access you can use:-

have set year to current year, but can be input param...


Dim dtefirst As Date

dtefirst = "01/01/" & Year(Now())

Do While dtefirst < "31/12/" & Year(Now())
dtefirst = DateAdd("d", 1, dtefirst)
Debug.Print dtefirst
Loop
Go to Top of Page
   

- Advertisement -