try this:
select
case
when left(convert(varchar,Getda
when left(convert(varchar,Getda
else 'C' end
You can find a much more comprehensive user defined function for formatting times here:
http://sqlserver2000.datab
Main Topics
Browse All Topicshi,
assuming if i am having this set of times, how do i query which alphabet the current time falls within.
exmaple..... 23:54 would return me C
A 08:00 15:59
B 16:00 23:50
C 23:51 07:59
thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
try this:
select
case
when left(convert(varchar,Getda
when left(convert(varchar,Getda
else 'C' end
You can find a much more comprehensive user defined function for formatting times here:
http://sqlserver2000.datab
hi,
try this
SELECT GETDATE(), * FROM TEST
WHERE
LEFT(RIGHT(CONVERT(VARCHAR
LEFT(RIGHT(CONVERT(VARCHAR
this is the result
(No column name) id time1 time2
2007-06-26 15:59:07.450 a 08:00 15:59
hth
Okay, I think this is the best way to go about it, but I'm not certain. Given that you've got a granularity of one minute, I think your time should be in minutes. Thus, if you were to take this query:
SELECT
Alphabet,
CurrentTime = DATEADD(mi, DATEDIFF(mi, DATEDIFF(d, 0, GETDATE()), GETDATE()), 0),
StartTimeGroup1 = CAST(StartTime AS DateTime),
EndTimeGroup1 = CAST(CASE WHEN EndTime < StartTime THEN '23:59' ELSE EndTime END AS DateTime),
StartTimeGroup2 = CAST(CASE WHEN EndTime < StartTime THEN '00:00' ELSE NULL END AS DateTime),
EndTimeGroup2 = CAST(CASE WHEN EndTime < StartTime THEN EndTime ELSE NULL END AS DateTime)
FROM Times
and modify it slightly, you'll get:
SELECT
Alphabet
FROM Times
WHERE
DATEADD(mi, DATEDIFF(mi, DATEDIFF(d, 0, GETDATE()), GETDATE()), 0)
BETWEEN CAST(StartTime AS DateTime)
AND CAST(CASE WHEN EndTime < StartTime THEN '23:59' ELSE EndTime END AS DateTime)
OR
DATEADD(mi, DATEDIFF(mi, DATEDIFF(d, 0, GETDATE()), GETDATE()), 0)
BETWEEN CAST(CASE WHEN EndTime < StartTime THEN '00:00' ELSE NULL END AS DateTime)
AND CAST(CASE WHEN EndTime < StartTime THEN EndTime ELSE NULL END AS DateTime)
This should work for all times and should be adaptable should you decide to change your coding scheme.
TNC
Business Accounts
Answer for Membership
by: Devil666Posted on 2007-06-26 at 03:36:18ID: 19362348
hi there,
, GETDATE(), 126), 12), 8) BETWEEN CONVERT(DATETIME, TIME1) AND CONVERT(DATETIME, TIME2)
try the following
SELECT * FROM Table
WHERE LEFT(RIGHT(CONVERT(VARCHAR
hth