我有一个查询,希望按月和年分组,因此:
GROUP BY ... Month(Deductions.USDate), Year(Deductions.USDate) ...但是由于GROUP BY,我需要在主select查询中使用这些内容,因此:
SELECT Month(Deductions.USDate)&"/"&Year(Deductions.USDate)这给了我8/2012,11/2011等等。这很好,但它是一个字符串,而不是日期,所以我不能正确地查询它。
我试过做类似下面这样的事情,但得到了一个类型不匹配。怎么啦?
CDATE("1/"&Month(Deductions.USDate)&"/"&Year(Deductions.USDate)发布于 2012-12-01 01:10:30
我认为你正在寻找这个:
DateSerial(Year(Deductions.USDate), Month(Deductions.USDate), 1)这将返回给定年份和月份的日期,并且日期始终设置为1。
https://stackoverflow.com/questions/13649378
复制相似问题