Sqlite日期查询
生活随笔
收集整理的這篇文章主要介紹了
Sqlite日期查询
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
查詢?nèi)掌?/p>
一、使用Between AND
select * from BatchNumberInfo where Start_Time Between '2019-1-01 00:00:00' AND '2019-7-12 23:59:59'
二、使用>,<
select * from BatchNumberInfo where Start_Time > '2019-1-01 00:00:00' and Start_Time < '2019-12-12 23:59:59'
注意:sqllite的datetime字符串形式第一個(gè)是"yyyy-M-dd HH:mm:ss",第二個(gè)是'yyyy-M-dd hh:mm:ss'
/// <summary>/// 按日期查詢/// </summary>private string QueryByDate(){string date1 = this.inquirePage.dateTimePicker1.SelectedDate?.ToString("yyyy-M-dd HH:mm:ss");DateTime temp1;DateTime temp2;string date2 = string.Empty;if (this.inquirePage.dateTimePicker2.SelectedDate != null){temp1 = this.inquirePage.dateTimePicker2.SelectedDate.Value;temp2 = new DateTime(temp1.Date.Year, temp1.Date.Month, temp1.Date.Day, 23, 59, 59);date2 = temp2.ToString("yyyy-M-dd HH:mm:ss");}if (date1 == null || date2.Equals(string.Empty)){MessageBox.Show("時(shí)間格式錯(cuò)誤!");return string.Empty;}string sql = "select * from BatchNumberInfo where Start_Time > '" + date1 + "' and End_Time < '" + date2 + " '";return sql;}?
總結(jié)
以上是生活随笔為你收集整理的Sqlite日期查询的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: web前端 | 博客(八)用户信息修改功
- 下一篇: redis5.0.5版本搭建集群