在mysql中使用strtotime或Timestamp选择

时间:2013-09-13 23:12:30

标签: mysql strtotime

我正在尝试选择其记录中的日期pubMonth + pubYear已经过去的作者。我已经尝试了几种WHERE语句的组合,但它们都没有消除大于$今天的记录,这是唯一的问题。

这就是我现在所拥有的:

$today = strtotime(date("Y-m-d"));
mysql_select_db($xxxxxxxxxx, $xxxxxxx);
$query_rsfindAuth = "SELECT Author.FirstName, Authors.level2, Authors.pubMonth, Authors.pubYear 
FROM Authors 
WHERE (UNIX_TIMESTAMP(Author.pubMonth+Author.pubYear) 
    < $today) AND level2 = 'Nature'

但是我已经尝试过这些,因为我有点在黑暗中拍摄。

WHERE ((Authors.pubMonth+Authors.pubYear )  < " . $today . ")   AND level2 = 'Nature'
WHERE (Authors.pubMonth+Authors.pubYear )   < $today        AND level2 = 'Nature'
WHERE " . strtotime(pubMonth.pubYear ) . "      < $today)       AND level2 = 'Nature'
WHERE pubMonth+pubYear)             < $today)       AND level2 = 'Nature'
WHERE (UNIX_TIMESTAMP(pubMonth+pubYear )    < $today)       AND level2 = 'Nature'
WHERE UNIX_TIMESTAMP(pubMonth+pubYear )     < " . $today . ")   AND level2 = 'Nature'

一如既往,感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

WHERE UNIX_TIMESTAMP(CONCAT_WS('-', gradYear, gradMonth, '01')) < '$today'