mysql - SQL date logic to fetch the values -
need sql logic
- if enter sys date 15th has fetch values 1-15th.
- if enter date following month 2nd has fetch 15th 2nd.
example
sys date april 15th - april 1 april 15th date values needs fetch. sys date may 2nd - april 15th may 2nd date values needs fetch.
please suggest
so general methodology you'd need function return day number in month, , 2 case statements each return particular date boundary. date arithmetic used convert system date upper , lower boundaries required, on oracle you'd use trunc(sysdate,'mm') , add_months(...,n) , add days on integers.
date functions here: http://docs.oracle.com/cd/b28359_01/server.111/b28286/functions001.htm
can't mysql functions -- doubtless they're documented somewhere.
you'll end ...
date_col > case <function on sysdate> when < 15 <function lower bound case 1> when < 15 <function lower bound case 2> end , date_col < case <function on sysdate> when < 15 <function upper bound case 1> when < 15 <function upper bound case 2> end ,
Comments
Post a Comment