Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How about if you need to pick the last 3 months prior to sysdate?


For example:

SQL
variable rundate varchar2(15);
execute :rundate :=to_char(sysdate);

variable Month1 varchar2(15);
execute :Month1 :=add_months(:rundate,-3);



But I only want orders in month vs. since exact date. If today is Mar 23, 2013 and I want previous month's order data, I don't want data from Feb 23rd to now. I just want Feb-13 orders.

How would you do that?



Thanks,
Adam
Posted
Updated 24-Mar-13 1:16am
v2

 
Share this answer
 
try this
SQL
variable Month1 varchar2(15);
execute :Month1 :=to_char(add_months(:rundate,-3),'MON-DD');
 
Share this answer
 
Thank you. I tried the to_char previously but didnt work. But seems to be fine now.
 
Share this answer
 
Comments
pryashrma 25-Mar-13 1:02am    
post d reply to solution in comment section! to send notification to the member

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900