SQL Scrapbook

Short and simple SQL Server posts

Archive for October 2010

SQL Date Cheat Sheets

leave a comment »

This post will show the commonly used queries to play with date functions in SQL Server. And yes i hope to update this list frequently.
Currently the following script has queries to:
Select two digit month, Select the first and last day of the month…

 --query to select month in two digits
SELECT	[TwoDigitMonth]
--select first day of month
 SELECT	[FirstDayofMonth]
--select last day of month
 SELECT	[LastDayofMonth]

You can replace the GETDATE() with a variable to use this for any month.

Written by sqlscrapbook

October 20, 2010 at 7:46 pm

Posted in TSQL