當前位置:
首頁 >
Sqlite日期查询
發布時間:2023/12/20
27
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Sqlite日期查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
查詢日期
一、使用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字符串形式第一個是"yyyy-M-dd HH:mm:ss",第二個是'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("時間格式錯誤!");return string.Empty;}string sql = "select * from BatchNumberInfo where Start_Time > '" + date1 + "' and End_Time < '" + date2 + " '";return sql;}?
總結
以上是生活随笔為你收集整理的Sqlite日期查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: web前端 | 博客(八)用户信息修改功
- 下一篇: redis5.0.5版本搭建集群