简体   繁体   English

如何使用python获取ms Access中当前日期的所有数据?

[英]How to get all the data for the current date in ms Access using python?

This is the picture of my data in access: 这是我的访问数据的图片:

MS-ACESS表

And below is the code for getting all the data for the current month: 下面是获取当月所有数据的代码:

def access():
    l =[]
    conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\GOBOTIX\Desktop\dbSamp64.mdb;')
    cursor = conn.cursor()
    cursor.execute('select * from Table1 where Month(DateTime)=Month(Date())')

    for row in cursor.fetchall():
        l.append(row)

How can I obtain all the data for the current date? 如何获取当前日期的所有数据?

Could the answer that you are looking for be as simple as: 您所寻找的答案是否可能像以下这样简单:

select * from Table1 where [DateTime] >= Date() and [DateTime] < Date()+1

Alternatively: 或者:

select * from Table1 where DateValue([DateTime]) = Date()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM