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
 dateadd() in where clause

Author  Topic 

smvr99
Starting Member

2 Posts

Posted - 2007-02-07 : 03:18:32
Hello,

I've a problem retrieving records when i do the following:

select name1, spousebday
from TABLEa
where DatePart("d",DateAdd("m",1,"1/31/" & Year([spousebday]))) = 29;


It works when the Year is hard-coded, ie:


select name1, spousebday
from TABLEa
where DatePart("d",DateAdd("m",1,"1/31/2004"))) = 29;


I just want to distinguish if the record is leap year or not.


Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-07 : 03:28:11
In MS ACCESS, dates are usually enclosed with #, not ".

What are you trying to accomplish? Maybe there is an easier way to get what you want?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

smvr99
Starting Member

2 Posts

Posted - 2007-02-09 : 04:13:31
I thought about my problem like you suggested, did some research and took another approach altogether. More than one way to skin a cat!
Thanks anyway.

My WHERE clause is now -

WHERE format(spousebday,"mm-dd-") & format(date(),"yyyy") = Format([enter the date], "mm-dd-yyyy")
and spousebday is not null;

I was going a little overboard with the date comparisons in Access.
Go to Top of Page
   

- Advertisement -