Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > SQL SERVER (TECHNET) > time(urgent)
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 25th July 09:12
shif
External User
 
Posts: 1
Default time(urgent)



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.
--
Thanks
  Reply With Quote


  sponsored links


2 25th July 09:14
hugo kornelis
External User
 
Posts: 1
Default time(urgent)



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 http://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
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
  Reply With Quote
3 25th July 09:15
shif
External User
 
Posts: 1
Default time(urgent)


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
  Reply With Quote
4 25th July 09:17
hugo kornelis
External User
 
Posts: 1
Default time(urgent)


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
--
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666