CodeBetter

 
Filed under

tsql

 

Get Date From DateTime In SQL

Something I need to do from time to time is get just the date part of a datetime value in SQL.  I found a cool way to do it on SQLJunkies today.

select convert(varchar,DateColumn,101)

The 101 means “mm/dd/yyyy” format, but there are a bunch of other codes you can use.  108 will return just the time “hh:mm:ss” for instance.

Update: 101 includes 4 digit year 'yyyy'.  A code of 1 would apparently be "mm/dd/yy", according to user comments.  Thanks!

A cool way to get date from DateTime in SQL!!

Filed under  //   SQL   T-SQL  

Comments [0]

Correcting DATETIME values (and Agent!) due to an incorrect system date

Check out this website I found at sqlblog.com

Filed under  //   T-SQL  

Comments [0]

Automated Index Defrag Script

A good solution to improve database performance.

http://sqlfool.com/2009/03/automated-index-defrag-script/

Filed under  //   T-SQL  

Comments [0]