x
login about faq Site discussion (meta-askssc)

Dateadd function & CURRENT_TIMESTAMP

How do I return the date of 10/01/2009(first day of previous month) when using DATEADD function and CURRENT_TIMESTAMP.

more ▼

asked Nov 04 '09 at 06:45 PM in Default

Dave 7 gravatar image

Dave 7
11 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
SELECT [Now] = CURRENT_TIMESTAMP,            
    [1st of this month] = DATEADD(Month, DATEDIFF(Month, 0, CURRENT_TIMESTAMP), 0),            
    [1st of last month] = DATEADD(Month, DATEDIFF(Month, 0, CURRENT_TIMESTAMP)-1, 0)            
more ▼

answered Nov 05 '09 at 12:27 AM

Kristen gravatar image

Kristen ♦
2.2k 6 7 10

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1611
x84

asked: Nov 04 '09 at 06:45 PM

Seen: 1117 times

Last Updated: Nov 05 '09 at 12:28 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.