Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 datetime value comparison

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-09 : 09:41:59
Eng writes "We have a field in a table that has a DATETIME data type. This field is set with either GETDATE(), OR the date of '12/31/2075' depending on the user's action. The table is unique with JOB_ID(int) and ExpireDate(datetime) Fields.

SAMPLE Data in SQL Table:
-------------------------
Job_ID ExpiredDate OtherFields
------ ----------- -----------
21 2000-12-31 00:00:00.000 aaaaaaaaaa
21 2000-06-06 12:04:38.647 expired job3
21 2000-03-06 11:40:38.647 expired job2
21 2000-11-07 16:33:46.890 expired job1
Scenario 1:
-----------
When a user selects the job that HAS NOT been expired yet (i.e. ExpireDate='12/31/2075').....

In the ASP pagesthe values of these two fields are passed through another ASP page using the querystring. [i.e. Go2NewPage.asp?Job_ID=21&ExpireDate='12/31/2075'......

The SQL created on the "Go2NewPage.asp" is [Select * from JobTypes where Job_ID = 21 and ExpireDate = '12/31/2075']

That works fine. This brings back the record.


Scenario 2:
-----------
When a user selects one of the jobs that HAS been expired on 11/07/2000 ......


In the ASP pages, the values of these two fields are passed through another ASP page using the querystring. [i.e. Go2NewPage.asp?Job_ID=21&ExpireDate='11/7/00 4:33:47 PM'

The SQL created on the "Go2NewPage.asp" is [Select * from JobTypes where Job_ID = 21 and ExpireDate = '11/7/00 4:33:47 PM']

That doesn't bring me back the record that I wanted!!!:-(

Is it because it's doing the string comparsion on the date? (2000-11-07 16:33:46.890 VS. '11/7/00 4:33:47 PM') How can I get this to work?

HELP!!!!!!!"
   

- Advertisement -