I don't know whats going on here, but here is my table (budget) with select * from budget
:
|budget_id|as_of_date|quarter_1|quarter_2|quarter_3|quarter_4|
|1 |15-MAY-16 |400 |100 |100 |100
So say if I wanted to calculate sum for all quarters on the given date(15th May of 2016) or before I would use this query :
select as_of_dt from budget where as_of_dt <= to_date('2016-05-15', 'yyyy-MM-dd');
This query returns nothing:
select (quarter_1 + quarter_2 + quarter_3 + quarter_4) from budget where as_of_dt <= to_date('2016-05-15', 'yyyy-MM-dd');
However if I add one day to this :
select (quarter_1 + quarter_2 + quarter_3 + quarter_4) from budget where as_of_dt <= to_date('2016-05-16', 'yyyy-MM-dd');
I get the right result 700
. I want to get all budget records before or equal to a given date string, why is the equal not working?
This might be a hint but I don't get it :
select to_date(as_of_dt, 'yyyy-MM-dd') from budget;
=> 16-MAY-15
select as_of_dt from budget;
=> 15-MAY-16
Somehow the year gets flipped or whatever is happening here, what do I do to get the right output with both equal and less than a given date ?