0

I wanna convert DateTime to VarChar.

it seams it so dublicated question

but wait a minute.

the next link is awesome:

How to convert DateTime to VarChar

but it is not effect to my question.

my output is neer to format 101

CONVERT(varchar(10), [MyDateTimecolumn], 101)

Output:

04/21/2000

I Wanna the output without zero in month

Requested Output

4/21/2000

is it applicable, without using any string function (like substring, replace, ... etc) ?

Updated The requested code is should be runnable on SQLServer2005, SQLServer2012 & Sybase

Community
  • 1
  • 1
ahmed abdelqader
  • 3,409
  • 17
  • 36

1 Answers1

0

If you are using SQL 2012 or higher you can achieve it using the FORMAT function native to SQL.

FORMAT(YourDate, 'M/dd/yyyy')
TT.
  • 15,774
  • 6
  • 47
  • 88
ThatChris
  • 752
  • 1
  • 4
  • 18