假设表里存储时间字段叫 [createTime];表名叫ta
selectfrom ta
where [createTime] between GETDATE() and (DATEDIFF(dd,[createTime], GETDATE()) = 30)
DATEDIFF(dd,[createTime], GETDATE()) = 30 就是当前日期前30天
sql=sql & " and (produceyear between "& produceyearstart &" and "& produceyearstop &")
and (produceweek between "& produceweekstart &" and "& produceweekstop &") "
and是多加一条条件而between and是条件里面的用法,类似in,>。是可以在一起用。
例如:
select from table_namewhere number between 1 and 100
and col_name='XXX'
and id between 200 and 300
and col_name2='XXXX';
以上就是关于SQL数据库怎么查询,between 当前日期 and 当前日期前30天,之间的数据全部的内容,包括:SQL数据库怎么查询,between 当前日期 and 当前日期前30天,之间的数据、sql 语言中的BETWEEN问题请教、sql语句中and和between and能在一块用吗等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)