0

I need to convert date as '25/10/2022' to YYYY-MM-DD. I am doing it as

select convert(varchar,'25/10/2022',106);

But it showing me the date as it is without converting. How should I convert it into required format.

Sumeet Kumar
  • 321
  • 4
  • 17
  • Does this answer your question? [How to get a date in YYYY-MM-DD format from a TSQL datetime field?](https://stackoverflow.com/questions/889629/how-to-get-a-date-in-yyyy-mm-dd-format-from-a-tsql-datetime-field) – Jonas Metzler Jan 11 '23 at 07:02
  • Does this answer your question? [Converting UK format date to datetime](https://stackoverflow.com/questions/15275813/converting-uk-format-date-to-datetime) – gre_gor Jan 11 '23 at 07:05

1 Answers1

1

Try this:

SELECT CONVERT(DATE,'25/10/2022',103) AS date_type_col
      ,CONVERT(VARCHAR(10), CONVERT(DATE,'25/10/2022',103) , 121) AS text_type_col
gotqn
  • 42,737
  • 46
  • 157
  • 243