Groups | Blog | Home
all groups > sql server mseq > december 2005 >

sql server mseq : time(urgent)


shif
12/29/2005 7:18:02 AM
Hi
How can i take time > hh:mmAM/PM and time < hh:mmAM/PM from a datetime field.
please give me a sample query for this.
--
shif
1/3/2006 9:28:02 PM
HI
Actualy i have a datetime field (entrydt) in my table,how can i fetch data
where
transaction between 8.30am and 4.30 pm from entrydt field.
--
Thanks


[quoted text, click to view]
Hugo Kornelis
1/3/2006 11:50:26 PM
[quoted text, click to view]

Hi shif,

I'm not sure if I understand your question. Maybe you could clarify a
bit, for instance by providing CREATE TABLE and INSERT statements and
expected output. Check out www.aspfaq.com/5006.

In the mean time, you might want to loom up CONVERT in Books Online and
see if this suits your need.

Best, Hugo
--

Hugo Kornelis
1/5/2006 8:52:27 PM
[quoted text, click to view]

Hi shif,

If the entrydt is populated with time only (i.e. the datepart is left at
the default 1/1/1900 value), you can use

WHERE entrydt >= '08:30:00'
AND entrydt < '16:30:00'

In this case, an index on the entrydt column can be used to locate the
matching rows.

But if entrydt contains different date parts, you'll have to use
something like the below, which (unfortunately) requires a table or
index scan to find the matching rows:

WHERE CONVERT(char(8), entrydt, 108) >= '08:30:00'
AND CONVERT(char(8), entrydt, 108) < '16:30:00'

Best, Hugo

--
Angband spoilers: http://ourworld.compuserve.com/homepages/hugo_kornelis/Angband/Spoiler/index.htm
Angband UI Patch: http://ourworld.compuserve.com/homepages/hugo_kornelis/Angband/UIpatch/index.htm
AddThis Social Bookmark Button