Constraint on DATEDIFF in sql query

160 views Asked by At

I am working on sql assignment and got stuck at applying constraint on DATEDIFF. My query is like..

select   *,DATEDIFF('$add_date_start',submitted_date) as d1,DATEDIFF('$add_date_end',submitted_date) as d2 from table where DATEDIFF('$add_date_start',submitted_date)<=0

I have also tried

select   *,DATEDIFF('$add_date_start',submitted_date) as d1,DATEDIFF('$add_date_end',submitted_date) as d2 from table where 'conditions 'HAVING d1<=0

Both of the queries showing 0 results.. All I have to do is put constraint on DATEDIFF to select on the basis on that.

The results are fine when i put condition in php using mysqli_fetch_array,something like...

while($row = mysqli_fetch_array($result){ if($row['d1'] <=0){ ///code } }

Any help will be great.. Thank You

0

There are 0 answers