Sunday, September 9, 2007

Date Without Time and other tricks

/*
date without time easiest way
no need to remember format as in convert and
no datatye conversions to varchar and back
*/

select dateadd(day,datediff(day,0,getdate()),0) as today

-- with convert and cast
select cast(convert(varchar(20),getdate(),112)as DATETIME) as today

-- First day of the month
select dateadd(month, datediff(month, 0, getdate()), 0)

No comments: