|
Posted by Erland Sommarskog on 11/29/05 10:35
sql guy123 (stoppal@hotmail.com) writes:
> I'm actually not really trying to format the date, but rather set the
> default value of the column(field) to the first day of the month.
>
> example: 1/1/2005, 2/1/2005, 3/1/2005 etc...
>
> What is the best way to get the default value in MS SQL to be the first
> day of the month?
convert(datetime, convert(char(6), getdate(), 112) + '01')
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|