繁体   English   中英

VB.NET如何通过检查数据库保存日期来创建提醒

[英]VB.NET How to create a reminder by checking database saved dates

我有这几行代码,将日期从datetimepicker保存到数据库列REMINDER中。

myCommand.CommandText = "Update kup_table SET REMINDER = @reminder Where ID = @theIDD"
myCommand.Parameters.AddWithValue("@reminder", DateTimePicker1.Value.Date)
myCommand.Parameters.AddWithValue("@theIDD", theID)
myCommand.ExecuteNonQuery()

由于数据类型为DATETIME,因此日期以2015-12-14 00:00:00的格式保存在我的数据库中。 如何将其与现在的日期进行比较? 如果保存的日期和今天的日期匹配,则提醒将消失。 我尝试使用此sql命令,但在提醒始终为零的地方仍然遇到麻烦。 提前致谢。

myCommand.CommandText = "Select COUNT(*) from kup_table Where REMINDER BETWEEN DATE() AND DATEADD('d', 1, DATE())"
mySqlConn.Open()
Console.WriteLine("Connected.")
count = myCommand.ExecuteScalar()
MsgBox("You have " + count.ToString + " reminder(s).")

Select COUNT(*) from kup_table Where DATE(REMINDER) = DATE(NOW())

DATE()函数仅返回datetime的日期部分。 (例如2015-12-14)

https://dev.mysql.com/doc/refman/5.5/zh-CN/date-and-time-functions.html#function_date

暂无
暂无

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

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