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
 General SQL Server Forums
 New to SQL Server Programming
 Get Recent Event in Specific Format (Time Based)

Author  Topic 

ram1986
Starting Member

6 Posts

Posted - 2014-12-17 : 07:04:05
Friends,

I have event table with below sample value :
table name : Events

EventId EventName EventDateTime StartTime
----------------------------------------------
1 Event1 2014-12-16 00:00:00.000 4:30 PM
2 Event2 2014-12-16 00:00:00.000 8:00 PM
4 Event4 2014-12-17 00:00:00.000 10:30 AM
3 Event3 2014-12-08 00:00:00.000 11:25 AM
1 Event1 2014-12-17 00:00:00.000 8:30 PM
2 Event2 2014-12-12 00:00:00.000 6:00 PM
3 Event3 2014-12-15 00:00:00.000 10:45 AM
5 Event5 2014-12-16 00:00:00.000 2:30 PM

I would like to get the next recent Event Based on the current date time, It should be like below format

Suppose today is 2014-12-17 and Current Time is 07:30 AM The expected result should be

NextEvent
------------
Upcomming Event : Event 4 - This Morning 10:45 AM

Specifically i am looking for a Format Like Below

If we have the event by TODAY, The result should be in below format
This Morning (12:00 AM to 12:00 PM)
This Afternoon (12:00 PM to 4:00 PM)
This Evening (4:00 PM to 7:00 PM)
Tonight (7:00 PM to 11:59 PM)

OR

If we have event by TOMORROW, then
Tomorrow Morning (12:00 AM to 12:00 PM)
Tomorrow Afternoon (12:00 PM to 4:00 PM)
Tomorrow Evening (4:00 PM to 7:00 PM)
Tomorrow Night (7:00 PM to 11:59 PM)

OR

Just Display Date and Start Time of Event
2014-12-19 by 5:00 PM

Please help me how to get this expected result in SP
Thanks in Advance

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-17 : 08:47:48
Please post the query you have so far. If you haven't got one, try to write it and post what you get.
Go to Top of Page
   

- Advertisement -