Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Syntex that still requires last weeks data

$
0
0
Hello

I have a piece of syntex which has been working perfectly, up until the new financial year (Today)

My SQL is:

decode(to_char(sysdate, 'Q'),
'1', trunc(add_months(sysdate, -9), 'Q'),
add_months(trunc(sysdate, 'YYYY'), 3))
AND next_day(sysdate,'SUNDAY')-7


This has been picking up the last financial year up until the last Sunday. However when i ran this data today 02/04/2013 our new financial year started on 01/04/2013 and now I get an error message:

Error: ORA-00920: invalid relational operator
(State:S1000, Native Code: 398)

As last Sunday was 31/03/2013 what I had hoped to show was a full year of data, but am returning 0 values

Could anyone help me rewrite the correct syntex so that I capture the entire financial year? and inaddition I need to know whether my above syntex will work when i run it next week and will pick up just April 2013 data?

01/04/2012 - 31/03/2013

Thanks
Helen

Viewing all articles
Browse latest Browse all 13329

Trending Articles