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
 Transact-SQL (2000)
 Select

Author  Topic 

stumbling
Posting Yak Master

104 Posts

Posted - 2009-03-22 : 17:35:43
Hi All

I have a table with 5 basic columns in it for events

Start Date Start Time End Time End Date EVENTid
23/03/2009 09:00AM 2:30PM 23/03/2009 1234
23/03/2009 10:00AM 12:01AM 25/03/2009 12345

What i need to do is select the start time where the End Time is less than the current time on todays date. I can get my code to work if the End Date is today but not if it is in the future, and the more i play with it the worse i get (LOL).

Any help would be appreciated.

Select "START TIME" from Table
Where Cast("End Time" as DateTime) >= Cast(LTRIM(RIGHT(CONVERT(VARCHAR(20),Getdate(), 0), 7))as DateTime)

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-23 : 00:22:26
try this once
Select STARTTIME from Table
where cast(endtime as datetime) <= cast(convert(varchar(15) ,getdate(),108) as datetime)
Go to Top of Page

stumbling
Posting Yak Master

104 Posts

Posted - 2009-03-24 : 18:22:27
Thanks for that i wil lgive it a go. Cheers Phil
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-24 : 22:36:23
welcome
Go to Top of Page
   

- Advertisement -