SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Script to return datetime as just date

By Paul Hickman, 2005/02/18

Total article views: 96 | Views in the last 30 days: 12

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

By Paul Hickman, 2005/02/18

Total article views: 96 | Views in the last 30 days: 12
Your response
 
 
Related tags

T-SQL Aids    
 
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com