php - How do I get first day of the year and last day of the year in SQL? -


i trying fetch set of information database based on datetime. using these statements fetch information:

$year_posts = $_get['year']; if ($_get['year'] = date("y")){     $state_sql = " , p.start_date = date_format(now() ,'%y-01-01') , p.end_date = now()"; } else{     $state_sql = " , p.start_date = date_format(now() ,'$year_posts-01-01') , p.end_date = date_format(now() ,'$year_posts-12-31')"; } 

if variable = 2015. how make fetch information 2015-01-01 00:00:00 current date?

and same goes 2014. how can fetch information 2014-01-01 00:00:00 2014-12-31 23:59:59?

i've tried looking on different threads, can't figure out. help?

i think trying figure out.

$year_posts = $_get['year']; if ($year_posts == date("y")){     $state_sql = " , p.start_date >= '".date('y')."-01-01 00:00:00' , p.end_date <= '".date('y-m-d h:i:s')."'"; } else{     $state_sql = " , p.start_date >= '{$year_posts}-01-01 00:00:00' , p.end_date <= '{$year_posts}-12-31 23:59:59'"; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -