Tairoc Tairoc - 1 year ago 82
SQL Question

How to convert date format from 05-JUN-99 to 050599?

I have gone through the suggested date formats here but didn't find any that meets my requirement.

I have the following date format:

05-JUN-99. 05 being dd as in day, JUN and the year 1999.

I have been asked to convert that to mmddyy (two digit month, two digit day and two digit year).

Any ideas how to do this?

Thanks for your assistance

vkp vkp
Answer Source

You can use convert here.

select convert(varchar(20),cast('05-JUN-99' as date),10)

--Output: 06-05-99

select replace(convert(varchar(20),cast('05-JUN-99' as date),10),'-','')

--Output: 060599

Date Styles from the documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download