Access数据库时间段数据查询
Access数据库时间段查询,时间用#括起来
举个例子,如果需要查日期在2020-01-01到2020-03-01范围之间的数据,时间条件要这样写Between #2020-01-01# and#2020-03-01#或者Date_str > #2020-01-01# and Date_str < #2020-03-01# ,这个相关当SQL Server数据库中的单引号,是一样的道理。
代码如下
sql = “where Date_str <= #”+ string . Format(“{0d/y/yyy}”,st.Value) +“#”;
sql = “where Date_str >= #”+ string . Format(“{0:dd/MM/yyyy}”,st.Value) +“#”;
sql = “where Date_str = #”+ string. Format(“{d/M/yyyy}”, st.Value) +“ #”;
sql = “where Date_str between #”+ string. Format(“{0:dd/MM/yyy}”,st.Value) +“#and#”+ string. Format(“{0:dd/MM/yyyy}”,st2.value) +“#”;