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
 Date Problem

Author  Topic 

Todd2006
Starting Member

18 Posts

Posted - 2009-02-24 : 22:04:31
Hello,

Here is my query


So if the date in reg_date is 02/23/2009 it wont show the records when the date is 02/24/2009 but I want to display the record till 02/25/2009.

So I want to display the record 2 days after the Reg_Date


strselect = "SELECT Distinct State from Registration where CDate(Reg_Date) > dateadd("day",-2,Date())"





but it doesnt work is the dateadd function right

Can someone tell me what change in the query I have to make.

todd

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-03 : 09:24:44
strselect = "SELECT Distinct State from Registration where Reg_Date > dateadd(day, -2, getDate())"



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-03 : 09:30:27
In ACCESS

strselect = "SELECT Distinct State from Registration where Reg_Date > dateadd("d", -2, Date())"

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-03 : 09:43:59
strselect = "SELECT Distinct State from Registration where Reg_Date > dateadd(""d""", -2, Date())" ???



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-03 : 10:11:14
Yes I forgot to notice it was part of assigning to variable

But I doubt it should be

strselect = "SELECT Distinct State from Registration where Reg_Date > dateadd(""d"", -2, Date())"

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -