Technical Article

Script to return datetime as just date

,

You can return the date as a string (varchar) in whatever date format you like by adding a 'style' to the CONVERT statement. Exmaples of style values are (two left hand columns):
1 101 USA mm/dd/yy
2 102 ANSI yy.mm.dd
3 103 British/French dd/mm/yy
4 104 German dd.mm.yy
5 105 Italian dd-mm-yy
6 106 - dd mon yy

The three-digit styles give you four-figure year values. Look up 'CAST and CONVERT' in SQL Server books for more configurations

From Paul Hickman
SCA Computing Ltd, Lyndhurst, UK

SELECT CONVERT(varchar, GETDATE(), 103)

Rate

3.33 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

3.33 (3)

You rated this post out of 5. Change rating