First day of month:
SELECT
DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
Last day of month:
SELECT
DATEADD(day,-1,DATEADD(month, DATEDIFF(month, 0, GETDATE())+1, 0))
Just the date of any datetime field:
SELECT
CAST(FLOOR(CAST(GETDATE()
AS
FLOAT))AS
DATETIME)
I Can't take credit for these, but they are just SOO handy - and fast.
Wednesday, December 16, 2009
A couple of nice DATE functions
Indsendt af
Rasmus Glibstrup
kl.
12:15
0
kommentarer
Etiketter: dates, programming
Subscribe to:
Posts (Atom)