SQL Server Query. Hey Ganesh!

Results 1 to 3 of 3

Thread: SQL Server Query. Hey Ganesh!

  1. #1
    Join Date
    Dec 1969

    Default SQL Server Query. Hey Ganesh!

    Hi,<BR><BR>I was wanting to know how I can have SQL Server display a date format with the year ending with 2 digits rather and 4<BR><BR>e.g.<BR><BR>23/10/2001<BR><BR>to<BR><BR>23/10/01<BR><BR>trippy

  2. #2
    Join Date
    Dec 1969

    Default rather a round about way...

    in sql i think this should be the way...any other guys having a simple solution in sql? But to avoid ambiguity for sql to understand the years property, its safe to refer years by four digit always...<BR><BR>select right(datepart(yy,convert(smalldatetime,"01/23/2001")),2)<BR><BR>in asp it is<BR><BR>aspvar=right(year(date()),2)<BR><BR>this works only if ur server date configuration is 4 digits or else it might retrun error.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default should work, but...

    this is IMHO the proper way to do it:<BR><BR>CONVERT(char(20),datefield,1) <BR><BR>You can replace the 1 with a lot of other numbers. (for example 103 displays as dd/mm/yyyy) Check the T-SQL docs for the CONVERT function for a complete list.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts