Concatonating year using date parameter with extract function

70 pts.
Tags:
SQL Server Query

I have a date parameter :ASOFDATE being entered as such: 01/01/2008.

I would like the following to print out in my columns: 2008-09.

The code I am using to attempt getting this is as follows: to_char(extract(year FROM to_date(:ASOFDATE, 'DD-MM-YYYY'))) || '-' || substr(extract(year FROM to_date(:ASOFDATE , 'DD-MM-YYYY') + 365), 3,2) The information that prints in my column is 8 –

Can you please show me the correct way to write the code so that I can get the desired result of 2008-09? Thank you



Software/Hardware used:
Microsoft Visual Studio 9.0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: