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,226
  • 15
  • 33

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,428
  • 6
  • 44
  • 84
ThatChris
  • 732
  • 1
  • 4
  • 17