Date formats

This code snippet is for getting different date formats

date: 05-sep-2009

SELECT CONVERT(char,GETDATE(),101) // 09/05/2009
SELECT CONVERT(char,GETDATE(),102) // 2009.09.05
SELECT CONVERT(char,GETDATE(),103) // 05/09/2009
SELECT CONVERT(char,GETDATE(),1) // 09/05/2009

you can replace the Getdate() with our table field.

Syntax :
Select Convert(char,,101) from table name.

Example :
 select convert(char,edate,101) from employee


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: