Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 January 27th, 2004, 08:06 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date Query

I've got a table of links. Each link has a start date and a stop date. I'm trying to eliminate the expired links from the recordset using DATE to get the current system date.

Here is my query:

set rs = DataConn.Execute("SELECT link_group, link_name, link_start, link_stop " & _
"FROM links " & _
"WHERE link_group = " & varGroupId & _
"AND link_stop > " & DATE & _
" ORDER BY link_name")

When I run the query, all the records return including the expired links (those that are less than today's date). Is there something wrong with the way I'm trying to use the date in my query? I'm using MS SQL 2000. Datatype is Date/Time. Records are formatted as mm/dd/yyyy in the table.

 
Old January 28th, 2004, 09:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I don't know exactly what your problem may be, but if link_stop is a datetime field, then you will need to include the date in either (') or the (#). Try that.

Hope this helps,

Brian
 
Old January 28th, 2004, 11:31 AM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The # hashes are used for Access. I tried it anyway and it didn't work. I also tried using the single quote (') , but no records returned.



 
Old January 28th, 2004, 11:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

SQL Server has the GETDATE() function to return the current system date/time, so you could change your query to:
set rs = DataConn.Execute("SELECT link_group, link_name, link_start, link_stop " & _
"FROM links " & _
"WHERE link_group = " & varGroupId & _
" AND link_stop > GETDATE()" & _
" ORDER BY link_name")

then you won't encounter any date conversion issues.

hth
Phil
 
Old January 28th, 2004, 07:27 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:)That did it! Thank you for helping me out.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Date query Problem yikchin Access 3 November 22nd, 2005 05:39 PM
date range query killroy Access 2 August 17th, 2005 02:14 PM
Query by date dsealer Access 11 November 9th, 2004 09:47 PM
Date based query when date is nvarchar MichaelTJ SQL Language 4 January 12th, 2004 09:57 PM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





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