Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 12th, 2005, 09:39 PM
SoC SoC is offline
Authorized User
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select records not equal to current date


Not sure where this question fits, but it's fairly straightforward.

I have an ASP page with an SQL statement like so:

SELECT * FROM myTable WHERE status = 1 ORDER BY dateAdded

I have another field called expiryDate. I want to modify the SQL so that it does not return records which have passed their expiryDate.

However, most records will have a null value in their expiryDate field. If this is the case, I want them to be part of the recordset.

So I think I need something like this:

SELECT * FROM myTable WHERE status = 1 AND (expiryDate > GETDATE() OR expiryDate is null) ORDER BY dateAdded

Not sure what the syntax is.



Old July 12th, 2005, 09:59 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

Does you query not work, it looks fine to me. I would write it like:

SELECT * FROM myTable WHERE status = 1 AND ((expiryDate < GETDATE()) OR (expiryDate is NULL)) ORDER BY dateAdded;

FYI Its a good habit to include trailing semi colons at the end of all statements. Paste your queries into Query Analyser, change and run, change and run,.... to identify what works and what doesnt.

Wind is your friend
Old July 12th, 2005, 10:20 PM
SoC SoC is offline
Authorized User
Join Date: Jul 2004
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks very much Matt. That's working now. I just had to change your code to

 ... ((expiryDate > GETDATE()) ...

That's expiryDate greater than ...



Similar Threads
Thread Thread Starter Forum Replies Last Post
Current date format elayaraja.s XSLT 2 August 6th, 2008 03:08 AM
Append Query to current active records markizan Access 2 September 26th, 2006 08:33 AM
Current Date s15199d Reporting Services 2 April 3rd, 2006 12:38 AM
Current Date rgudino Java Databases 1 May 5th, 2005 03:09 AM
Current Date?? morpheus SQL Server 2000 2 November 27th, 2003 04:21 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.