Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plain SQL command for date selection

Status
Not open for further replies.

BleedingEdge

Technical User
Jul 14, 2005
10
US
Hi guys, first post here! Hope you can answer or set me on the right path.

I'm building a DB in Lotus Approach. Using latest version and built with Dbase IV.

Okay, so I got the DB built and am now trying to build queries. Approach doesn't seem to let you build in variables or expressions, just it's default wizard stuff. So I need help!

In Approach, what's the best way to build/test SQL queries?

Case in point. I need to build a query which selects all records which have a certain date that is at least OLDER then 45 days from todays date.

So it basically reads the date field, and if the date is more then 45 days ago, that field is selected. It's a reverse date select. Like most searches you are searching for the "newest" dates, I have to search for all dates that are older then 45 days and so on.

But in Approach, the wizard gives no such help. And I am not familiar with the process of writing a query file or using LotusScript. How can I make this query and others like it?
The point being, is there a way, using raw SQL ONLY and no code or programming or variables, to select fields based on the date like this?

Thanks a bunch!
 
FYI, this is a MS SQL Server forum. You should probably post this question in a forum dedicated to one of the products you are using.

--James
 
I know, I wasn't really sure WHAT forum to post in.

My question isn't about MS or Approach or anything. My questing is simply to build a query.

I need a plain jane (sans any code) strait SQL query that selects ALL records that are OLDER then todays date minus 45 days.

It's just the query I need. Thanks.
 
well, you see, that's the whole point of posting in the right forum

in sql server, it's WHERE datecol < dateadd(d,-45,getdate())

in access, it's WHERE datecol < dateadd("d",-45,now())

in mysql, it's WHERE datecol < dateadd(curdate, interval -45 day)

especially where dates are concerned, there is no "plain jane sql"

do you have a sql reference manual for approach? look up its date functions

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top