Useless Blogging

December 16, 2007

Totally Random Crystal/SQL Trick

Filed under: SQL — steegness @ 8:22 pm

I wanted to put this up so I didn’t forget it. This is a trick to turn a field into a toggle, allowing for a default date range or a user-specified one. It’s made for Crystal, but would work for anything Oracle-based, I think, with some tweaking.

whateverdate between (decode(‘{?Timespan}’, ‘DEFAULT’, (Last_Day(Add_Months(SYSDATE, -2)) + 1), ‘{?StartDate}’)) and (decode(‘{?Timespan}’, ‘DEFAULT’, (Last_Day(Add_Months(SYSDATE, -1)) + 1)

Thank you for your time.

Comments are closed.