0

如何将 news.time 设置为一年?我想找到 2012 年。

SELECT
    news.id, 
    news.Categoryid, 
    news.newsid, 
    news.Languageid, 
    news.createtime, 
    news.tags, 
    news.topic, 
    news.sub_topic, 
    news.[time], 
    news.content_s, 
    [Language].Languagename, 
    Category.Categorysubid
FROM
    (
        news 
        INNER JOIN
        [Language] 
            ON news.Languageid = [Language].Languageid
    ), Category

我尝试了这段代码,但它不起作用:

SELECT
    news.id, 
    news.Categoryid, 
    news.newsid, 
    news.Languageid, 
    news.createtime, 
    news.tags, 
    news.topic, 
    news.sub_topic, 
    news.[time], 
    news.content_s, 
    [Language].Languagename, 
    Category.Categorysubid
FROM 
    (
        news 
        INNER JOIN
        [Language] 
            ON news.Languageid = [Language].Languageid
    ), Category
WHERE ( YEAR(news.[time]) = YEAR(?) )
4

1 回答 1

0

年份是一个数字,因此不需要任何转换:

WHERE ( YEAR(news.[time]) = 2012)

您还可以使用日期间隔,这可能更有效:

WHERE (news.[time] >= #20120101# and news.[time] < #20130101#)
于 2013-06-19T17:38:10.100 回答