You are here: Re: Need Help Getting the day shift after midnight « MsSQL Server « IT news, forums, messages
Re: Need Help Getting the day shift after midnight

Posted by Erland Sommarskog on 12/02/06 23:39

Amy Smith (amoura00@hotmail.com) writes:
> the end time after mindnight will be always 6:00:00AM so from 00:00:00
> AM to 6:00:00 AM , it should go to the pervious day's shift 2 . Again my
> issue is when finding the that the start time fall withing that time how
> do I pretend the date as the previous date? Do I subtract the date ? Is
> there a function to do that ? thanks Roy

convert(char(8), dateadd(HOUR, -6, EndTime), 112)

The dateadd() functions brings the EndTime six hours back in time. The
convert to char(8) with code 112 strips of the time portion.

You can read more about dateadd and other datetime functions in Books
Online. You can also read about convert() under the topic CAST and CONVERT.

--
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

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