与Jet/Access数据库等效的Getdate().需要上个月的记录 [英] Getdate() equivalent for Jet / Access database. Need last month records
本文介绍了与Jet/Access数据库等效的Getdate().需要上个月的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读发布的其他问题,并发现许多示例来检索上个月的记录.我正在使用Visual Studio 2008查询构建器从Access mdb检索记录,当我输入以下查询时,它向我显示getdate不是有效函数的错误:
I was reading other questions posted and found many examples to retrieve last month records. I am using Visual Studio 2008 query builder to retrieve records from an Access mdb and when I enter the following query it is displaying me an error that getdate is not a valid function:
where [Transaction Date]
between dateadd(mm, datediff(mm, 0, dateadd(MM, -1, getdate())), 0)
and dateadd(ms, -3, dateadd(mm, datediff(mm, 0, dateadd(MM, -1, getdate())) + 1, 0))
从mdb中提取上个月记录的正确SQL查询是什么?
What is the correct sql query to extract last month records from an mdb?
这是我的查询,但是它给了我这个月的记录,也只需要上个月:
This is a query I have, but it is giving me records from this month also amd just need last month:
SELECT
[Product Code], [Description One], [Transaction Number], Quantity, [Sales Value], Cost, [Transaction Date], [Transaction Time], Department, [Type Code], Cashier, [Computer Name], [Customer Code]
FROM
[Product History]
WHERE
([Transaction Date] >= DATEADD('m', - 2, NOW()))
感谢您的帮助.
推荐答案
WHERE
DATEDIFF('m', [Transaction Date], DATE()) = 1
这篇关于与Jet/Access数据库等效的Getdate().需要上个月的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文