mysql - SQL date logic to fetch the values -


need sql logic

  1. if enter sys date 15th has fetch values 1-15th.
  2. 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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -