If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Date Searching

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-22-03, 04:00
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
Date Searching

My problem......

I have a SQL db that I need to search a date range on - on my form I have to fields that a user will enter 2 dates.

I need to search the db datetime field for date range specified on the form.

Can anyone help ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-23-03, 01:09
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
lets assume the 2 fields are startDate and endDate

Code:
SELECT * FROM tableName WHERE dateField >= '" & Request.Form("startDate") & "' AND dateField <= '" & Request.Form("endDate") & "'

or

SELECT * FROM tableName WHERE dateField BETWEEN '" & Request.Form("startDate") & "' AND '" & Request.Form("endDate") & "'
Reply With Quote
  #3 (permalink)  
Old 07-23-03, 03:01
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
HELP !

Hi Memnoch1207

Understand you reply - thanks, one thing im not sure of is that on my actual form fields do I have to specify anything as I am getting http error 500.

Can you help ?

Thanks


Quote:
Originally posted by Memnoch1207
lets assume the 2 fields are startDate and endDate

Code:
SELECT * FROM tableName WHERE dateField >= '" & Request.Form("startDate") & "' AND dateField <= '" & Request.Form("endDate") & "'

or

SELECT * FROM tableName WHERE dateField BETWEEN '" & Request.Form("startDate") & "' AND '" & Request.Form("endDate") & "'
Reply With Quote
  #4 (permalink)  
Old 07-23-03, 03:04
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
Hello

I have attached the search and results page if you can take a look ?

Any help appreicated !

Donald


Quote:
Originally posted by Memnoch1207
lets assume the 2 fields are startDate and endDate

Code:
SELECT * FROM tableName WHERE dateField >= '" & Request.Form("startDate") & "' AND dateField <= '" & Request.Form("endDate") & "'

or

SELECT * FROM tableName WHERE dateField BETWEEN '" & Request.Form("startDate") & "' AND '" & Request.Form("endDate") & "'
Attached Files
File Type: zip files.zip (4.4 KB, 15 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On