Sqlite日期比较不起作用 [英] Sqlite date comparison is not working

查看:105
本文介绍了Sqlite日期比较不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对SQLite中的日期进行比较,它没有比较,我正在使用下面写的这个查询。

I'm doing comparison of date in SQLite, it's not comparing, I'm using this query which is written below.

          var today =(DateTime)criteria.Today;

         var today = (DateTime)criteria.Today;

  IQueryable< Patient> createdTodayQuery = query.Where(
$
         patient =>

            patient.CreationDate.HasValue&&
patient.CreationDate.Value.Date == today

          &&!patient.IssuerOfPatientId.Contains(issuerDefinition));

 IQueryable<Patient> createdTodayQuery = query.Where(
                patient =>
                    patient.CreationDate.HasValue && patient.CreationDate.Value.Date == today
                    && !patient.IssuerOfPatientId.Contains(issuerDefinition));

在我的Sqlite数据库中,我已将DateTime2作为文本。

In my Sqlite database , i have taken DateTime2 as Text.

你能帮助我吗?问题是什么?

Can you help me out? what is the issue?

推荐答案

我没有看到你的例子中使用了DateTime2的位置,但如果你只是比较日期(没有时间部分)那么日期需要是相同的格式,如果它们是字符串。您可以拨打

ToShortDateString
(对于列和标准)以确保是这种情况。
I don't see where DateTime2 is used in your example, but if you are comparing just the date (without the time portion) then the dates need to be in the same format if they are string. You could just call the ToShortDateString (for both the column and criteria) to ensure this is the case.


这篇关于Sqlite日期比较不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆