如何比较sql记录日期字段 [英] how to compare sql record date field
本文介绍了如何比较sql记录日期字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个带有smalldate字段的sql表,我想比较字段的值(日期)与当前日期和前一个月,例如字段是8的2014年5月,当日期是2014年5月8日至2014年5月8日(一个月期间)时,我想在表格上进行比较是否有任何sql功能?
例如
Hello,
I have an sql table with a smalldate field, I want to compare the value (date) of the field with the current date and a month foreward, eg the field is 8th of may 2014, I want to compare on formload when the date is 8th of april until 8th of may 2014 (one month period) is there any sql function for this?
eg
select * from table1 where date = ?
或之间?我认为介于但是如何插入datenow或者我应该将值提取到vb并与date.now函数进行比较?
or between ? I think between exists but how to insert the datenow or shall I extract the value to vb and compare with date.now function?
推荐答案
尝试:
Try:
SELECT * FROM Table1 WHERE myDateColumn BETWEEN GETDATE() AND DATEADD(m, 1, GETDATE())
这篇关于如何比较sql记录日期字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文