0

所以,我在这里有这个查询:

$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 > servis_furnitor.kohezgjatja";

我知道最后一行是错误的,我的意思是我到那里还好.. 我有这个订单,他们有一个开始日期, formas.data_fillim我有今天的日期:

$today = date("Ymd"); 

所以两者之间的差异 $today-formas.data_fillim不应该大于servis_furnitor.kohezgjatja整数本身,它显示天数

formas.data_fillim

是一个日期类型..

我需要提取与今天日期和开始日期的差异不大于“kohezgjatja”中预定义的天数的所有数据

请任何帮助..谢谢

更新

$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 ) > servis_furnitor.kohezgjatja
ORDER BY formas.id DESC"
4

2 回答 2

0

声明的正确格式SELECT

SELECT ....
FROM...
WHERE ...
GROUP ....
ORDER BY...

所以在你的情况下,

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 )  > servis_furnitor.kohezgjatja
ORDER BY formas.id DESC
于 2013-02-23T14:05:37.500 回答
0

像这样的东西应该工作:

where formas.data_fillim <= DateAdd(day, servis_furnitor.kohezgjatja, getdate())

您可能需要在 servis_furnitor.kohezgjatja 前面加上一个减号,具体取决于您在那里存储的内容。

于 2013-02-23T14:14:35.863 回答