poolek3888
Programmer
Hello all. Thanks in advance for the help. My problem seemed like a simple one, but has turned into a big head ache.
I am basically selecting data in a certain time period that I allow the user to specify with the use of parameters. Now, in order to select that data, I ask for the user to input an ending date and ask how far back they would like to go. In my query, after SELECT, FROM, and WHERE, my query reads:
AND b.audit_timestamp between to_datemy_date,'MM-DD-YYYY') - INTERVAL '7' DAY and to_datemy_date,'MM-DD-YYYY')
You can see here that this will only go back 7 days. So I need a way to change "'7' DAY" into "'1' DAY" and "'1' MONTH." I figured I could make a new parameter for this and sub in the code I need, but it seems that wont work. I also checked out case and if statements, but they seem to only apply after SELECT and before FROM.
Do you have any advise for how I can make a WHERE statement be based on a variable?
Thanks all!
-Kyle
I am basically selecting data in a certain time period that I allow the user to specify with the use of parameters. Now, in order to select that data, I ask for the user to input an ending date and ask how far back they would like to go. In my query, after SELECT, FROM, and WHERE, my query reads:
AND b.audit_timestamp between to_datemy_date,'MM-DD-YYYY') - INTERVAL '7' DAY and to_datemy_date,'MM-DD-YYYY')
You can see here that this will only go back 7 days. So I need a way to change "'7' DAY" into "'1' DAY" and "'1' MONTH." I figured I could make a new parameter for this and sub in the code I need, but it seems that wont work. I also checked out case and if statements, but they seem to only apply after SELECT and before FROM.
Do you have any advise for how I can make a WHERE statement be based on a variable?
Thanks all!
-Kyle