Re: Date Range for SQL 2005
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 15 Jul 2007 23:08:45 +0200
On Fri, 13 Jul 2007 14:13:30 -0700, Aaron wrote:
I was reading the article and was unable to get some of queries to
execute. Can anyone help get these to work:
How to get the last day of the previous month? And the last day of the
current month?
SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP),
'19991231')
SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP),
'20000131')
Hi Aaron,
When I copy and paste these queries into SSMS, I get the desired
results: June 30 and July 31. Your request for help to get them to work
implies that you got different results. Could you expand on that?
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.
- References:
- Date Range for SQL 2005
- From: Aaron
- Re: Date Range for SQL 2005
- From: Roy Harvey
- Re: Date Range for SQL 2005
- From: Aaron
- Date Range for SQL 2005
- Prev by Date: Re: Date Range for SQL 2005
- Next by Date: Re: Establishing Precedence In ORDERBY Condition Causing Problems.
- Previous by thread: Re: Date Range for SQL 2005
- Next by thread: Effect of "Do not recompute statistics" option
- Index(es):
Relevant Pages
|