You are here: Re: Code for 1st day & the Last day of the Previous Month « MsSQL Server « IT news, forums, messages
Re: Code for 1st day & the Last day of the Previous Month

Posted by Ray via SQLMonster.com on 07/21/05 01:20

Ross,

Thank you so much ....

Ross Presser wrote:
>> Hi there,
>>
>[quoted text clipped - 8 lines]
>>
>> Regards,
>
>declare @d1 smalldatetime
>declare @d2 smalldatetime
>declare @d3 smalldatetime
>
>-- @d1 is the input date
>set @d1 = CURRENT_TIMESTAMP
>-- truncate hours, min, etc.
>set @d1 = convert(smalldatetime, floor(convert(float, @d1)))
>
>-- @d2 - last day of previous month
>
>set @d2 = dateadd(day, - datepart(day, @d1), @d1)
>
>-- @d3 - first day of previous month
>
>set @d3 = dateadd(day, - datepart(day, @d2) + 1, @d2)


--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-general/200507/1

 

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

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