date comparison (1 Viewer)

Beacher

Registered User.
Local time
Today, 00:35
Joined
May 13, 2005
Messages
11
Hey all,

I've got to show records from a table that are 45 days old or newer.. im not quite sure how to do this in SQL ...

Select field from table where date > (todaysdate-45).. as you can see..clueless lol any help is _greatly_ appreciated
 

Tim L

Registered User.
Local time
Today, 08:35
Joined
Sep 6, 2002
Messages
414
First off you should have posted this to the Queries forum...

Stored Date >=(Date()-45)

Tim
 

godofhell

Database Guru
Local time
Today, 00:35
Joined
May 20, 2005
Messages
180
What you want to do is set a query and under the field you are storing the dates enter in the criteria:
Between Date()-45 And Date()+45

If you are using a SQL Statement enter WHERE Datefield Between Date()-45 And Date()+45
Replace Datefield with the name of the field you are using to store the date values.
 

Tim L

Registered User.
Local time
Today, 08:35
Joined
Sep 6, 2002
Messages
414
godofhell said:
Between Date()-45 And Date()+45

Good alternative; shouldn't that be Between Date()-45 and Date() to get the records up to the current dat? Then again, by using Between are we not going to have to restrict some of the records from the part after the And? And I think that Beacher wanted all newer records, not just the ones that came up to today or 45 days in the future, at least that is how it came across to me in his post, although I may have misunderstood.

Tim
 

Users who are viewing this thread

Top Bottom