Click here to Skip to main content
16,016,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to convert below query from Oracle PL/SQL to MS SQL Server
to_date(to_char(cm_firstfinishdate,'MON YY'),'MON YY')

here cm_firstfinishdate = 2013-08-27 of datatype date

for.. to_char(cm_firstfinishdate,'MON YY')
I have done UPPER(RIGHT(CONVERT(VARCHAR(10), cm_firstfinishdate, 6),6))
which works fine,
how to convert the same to to_date
please assist me
Posted
Updated 6-Feb-14 22:40pm
v2

1 solution

CONVERT(DATETIME, '01 ' + UPPER(RIGHT(CONVERT(VARCHAR(10), cm_firstfinishdate, 6),6)))

It seems that you need to get the first day of the month.

In SQL Server you may use the following:

DATEADD(month, DATEDIFF(month, 0, cm_firstfinishdate), 0)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900