Note that there are some explanatory texts on larger screens.

plurals
  1. POSql query where condition with dates
    primarykey
    data
    text
    <p>So, i have this query here:</p> <pre><code>$strSQL = "SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added,servis_furnitor.id_servis,servis_furnitor.furnitori,servis_furnitor.kohezgjatja FROM formas LEFT JOIN servis_furnitor ON formas.furnitori = servis_furnitor.id_servis LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET ORDER BY formas.id DESC WHERE $today-formas.data_fillim &gt; servis_furnitor.kohezgjatja"; </code></pre> <p>The last row is wrong i know, i mean i'm okay up to there.. I have this orders, they have a starting date which is <code>formas.data_fillim</code> and i have the today's date :</p> <pre><code>$today = date("Ymd"); </code></pre> <p>So the difference between <code>$today-formas.data_fillim</code> shouldn't be bigger than <code>servis_furnitor.kohezgjatja</code> which is an integer itself and it shows the number of days</p> <pre><code>formas.data_fillim </code></pre> <p>is a datetype..</p> <p>I need to extract all data whose difference with today's date and their starting day isn't bigger than the number of days predefined in "kohezgjatja"</p> <p>Any help please.. Thanks</p> <p>UPDATES</p> <pre><code>$today = date("Y-m-d H:i:s", time()); echo $strSQL = "SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR, SMS_SERVISI.time_added, servis_furnitor.id_servis, servis_furnitor.furnitori, servis_furnitor.kohezgjatja FROM formas LEFT JOIN servis_furnitor ON formas.furnitori = servis_furnitor.id_servis LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET WHERE DATEDIFF ( day , '$today' , formas.data_fillim ) &gt; servis_furnitor.kohezgjatja ORDER BY formas.id DESC" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload