
April 23rd, 2008, 07:46 AM
|
 |
Slaprentice of Wolves
|
|
Join Date: Aug 2007
Location: Mossville, IL
|
|
Quote: | Originally Posted by db530 I'm working on a project where the date and time are two separate fields in a table. I need to query the database so my website shows everything from Start Date/Start Time to End Date/End Time.
I was told to combine the two in a string but then I still have the problem of not being able to search using between because they are in two separate fields. I'm really new at this so it may be a stupid question but does anyone have any ideas? Thanks |
I'm going to assume that the date and time are being stored as VARCHARs in the database (usual rant inserted here). To do this query, you'll need to convert the two fields into a date time value. Now my MS SQL is rusty, but something like
SQL Code:
Original
- SQL Code |
|
|
|
SELECT whatever FROM myTable WHERE Convert(datetime, aDate + ' '+ aTime, 109) BETWEEN startDate AND endDate
Should get you started.
__________________
Wolffy
------------------------
Teaching people to fish.
|