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)
 Event Schedule

Author  Topic 

Ferox
Starting Member

18 Posts

Posted - 2005-10-19 : 04:36:54
Hi guys!

I’m making a schedule–type application and I’ve got a table of events with a ‘start time’ and ‘end time’ (both datetime fields.) I’m trying to list the event that is currently on at the moment, but I’m having trouble pulling out the correct record.

This is an example of the data:

ID Event Start End
1 Opening 09:00 10:30
2 Discussion 10:30 12:00
3 Lunch 12:00 12:35
4 Discussion 12:35 14:00
5 Questions 14:00 15:00
6 Break 15:00 15:30
Etc

I’m trying to pull out the current active event, but sometimes it comes out wrong (at the end of the hour etc) How should I go about grabbing this record? Should I be using datediff someway?

Any help would be greatly appreciated! :)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 04:54:45
What is your expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Ferox
Starting Member

18 Posts

Posted - 2005-10-19 : 05:00:33
I plan to pull out the current event at the top (based on getdate()) and then the events after that below:

e.g. based on time now = 10:48am

2 Discussion 10:30 12:00 - CURRENT EVENT
3 Lunch 12:00 12:35
4 Discussion 12:35 14:00
5 Questions 14:00 15:00
6 Break 15:00 15:30
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 05:23:09
If Start and End columns are DateTime, then how do you store only Time part?

Try this

Select Columns from yourTable where GetDate() between Start and End

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Ferox
Starting Member

18 Posts

Posted - 2005-10-19 : 06:19:31
Thanks madhivanan that BETWEEN functionality worked brilliantly!

My datetime fields are actually stored as '01/01/1900 12:00:00' etc but I only ever use the time element.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 06:24:14
Well. Whenever you post questions post full value and dont truncate value

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Ferox
Starting Member

18 Posts

Posted - 2005-10-19 : 06:29:11
Ok sorry about that...and many thanks again! :)
Go to Top of Page
   

- Advertisement -