如果数据库中的日期是字符串格式,如何在LINQ中检查大于特定日期的日期。 [英] How to check Date greater than a specific date in LINQ if the date in database is in String format .

查看:216
本文介绍了如果数据库中的日期是字符串格式,如何在LINQ中检查大于特定日期的日期。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库表ApplicationErrorLog,其中ErrorDate以String格式存储我在网上尝试了各种示例但没有任何工作被困两天想要获得所有日期大于日期(ErrorDateFilterValue)即将到来来自数据库(ErrorDate)...

I have a database table ApplicationErrorLog in which ErrorDate is stored in String format i have tried various examples on the net but nothing is working "Been stuck for two days" Want to get all the dates greater than the date(ErrorDateFilterValue ) coming from database (ErrorDate) ...

list = (from t in objPowerSchoolAdminPortalEntities.ApplicationErrorLogs
                           where t.ErrorDate.CompareTo(ErrorDateFilterValue) <= 0
                           select t).ToList();



尝试制作iQueryable但它没有用 -


Tried to make iQueryable but it didnt worked -

AscendingQuery = AscendingQuery.Where(As => DateTime.Parse(DateTime.Parse(As.ErrorDate).ToShortDateString(), enUsDateFormat).ToString("yyyyMMdd") == ErrorDateFilterValue);



这是我要比较它的日期 - ErrorateFilterValue


this is the date with which i want to compare it - ErrorateFilterValue

IFormatProvider enUsDateFormat = new CultureInfo("en-US").DateTimeFormat;
                           objApplicationErrorLogModal.ErrorDateFilterValue = DateTime.Parse(TempDate.ToShortDateString(), enUsDateFormat).ToString("yyyyMMdd");



我可以将它转换为任何格式但不是来自数据库的格式。

任何建议和帮助都将是赞美的。

感谢提前。


I Can Convert it to any format but not the one coming from Database .
any kind of suggestions and help will be appriciated .
Thanks IN Advance.

推荐答案

试试这个,它可能有帮助



比较Linq查询中的日期时间 [ ^ ]
Try this , it may help

Compare Datetime in Linq Query[^]


这篇关于如果数据库中的日期是字符串格式,如何在LINQ中检查大于特定日期的日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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