You are here: Re: Search Between Times « MsSQL Server « IT news, forums, messages
Re: Search Between Times

Posted by Erland Sommarskog on 04/22/06 13:15

(balaji.balaraman@gmail.com) writes:
> Where (( Month like '200501%' ) and (Time between '2005-01-01
> 02:00:00.000' and '2005-01-31 06:00:00.000))
>
> group by month, time
>
> order by month
>
> PRoblem: What I want is all the volume between 2am and 6am on every day
> of the month?
>
> The above query naturaly will give me everything between first and last
> of the month...

convert(char(8), Time, 108) BETWEEN '02:00:00' AND '06:00:00'

You find convert under the topic CAST and CONVERT in Books Online,
where you can see the different format codes (108 in this example) that
are available.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация