x

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, 2009 at 06:45 PM in Default

avatar image

Dave 7
11 1 1 3

(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, 2009 at 12:27 AM

avatar image

Kristen ♦
2.2k 7 11 14

(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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2076
x80

asked: Nov 04, 2009 at 06:45 PM

Seen: 1886 times

Last Updated: Nov 05, 2009 at 12:28 AM

Copyright 2016 Redgate Software. Privacy Policy