All Forums General
aaibinder 9 posts Joined 08/16
30 Aug 2016
Last 6 Month in Query - Failing on August 30

...WHERE DB.LOG_DATE > DATE - INTERVAL '6' MONTH;
 
This has been working for weeks, until today. I wasn't sure what broke my script until I tried dropping the date requirement and then it started working perfectly. 6 month ago is February 30, I am guessing, by TD logic, which doesn't exist.
Any general solutions?
 
 
 

dnoeth 4628 posts Joined 11/04
30 Aug 2016

This is not Teradata logic, it's stupid Standard SQL (In fact you can't use INTERVAL-syntax for both YEAR and MONTH).
That's why there's ADD_MONTHS :-)

WHERE DB.LOG_DATE > ADD_MONTHS(DATE,-6);

Dieter

aaibinder 9 posts Joined 08/16
30 Aug 2016

Thank you!

You must sign in to leave a comment.