Page 1 of 1

MMYY + oconv?

Posted: Mon Mar 03, 2008 1:30 pm
by jshurak
I have a job that extracts a monthly table. The table has the 2 digit month and year format at the end. this is what I've been using

Code: Select all

If ReportDate = 0 Then
ReportDate = CONVERT("/","",OConv(@DATE - 7, "D/MY[Z,2]"))
End
It worked normally........until we rolled over to January. This bit of code doesn't use '0' as part of the month. ie. 108 instead of what I need '0108'.

Any suggestions?

Posted: Mon Mar 03, 2008 1:33 pm
by DSguru2B
What is your target data type?

Posted: Mon Mar 03, 2008 1:35 pm
by jshurak
I'm sorry. This is just needed to pass the correct table name. Its the table name that has the 'mmyy' at the end.

Posted: Mon Mar 03, 2008 1:36 pm
by DSguru2B
Ok. Use the following

Code: Select all

If ReportDate = 0 Then 
ReportDate = CONVERT("/","",OConv(@DATE - 7, "D/MY[2,2]")) 
End

Posted: Mon Mar 03, 2008 1:40 pm
by jshurak
thanks!