日期转换问题 [英] date converting problem

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

问题描述



我必须将日期(dd / mm / yyyy 00:00:00 am)转换为mm / dd / yyyy的问题,以便比较Linq中的两个日期。

请帮帮我


i have to problem to convert date (dd/mm/yyyy 00:00:00 am) to mm/dd/yyyy in where condition to compare two date in Linq.
please help me

推荐答案

在您的数据库中,您应该将日期保留为日期。无需将日期转换为数据库中的特定字符串。将数据作为数据处理,并在您的应用程序中进行转换和格式化。



比较日期:



In your database you should keep dates as dates. There''s no need to convert dates to a specific string in your database. Treet data as data and do converting and formatting in your application.

Compare dates:

date1.ToString("yyyyMMddHHmm") == date2.ToString("yyyyMMddHHmm")



ToString(格式)取决于比较应该有多准确。



你试过什么?


ToString(format) depends on how accurate the comparing should be.

What have you tried?


这样的东西

dateObj1.ToString(mm / dd / yyyy)= dateObj2;

其中dateObj2的格式为mm / dd / yyyy
something like this
dateObj1.ToString("mm/dd/yyyy") = dateObj2;
where dateObj2 is of format "mm/dd/yyyy"


Convert.ToDateTime (你的数据时间)。ToString(MM / dd / yyyy);
Convert.ToDateTime( "Your data time").ToString("MM/dd/yyyy");


这篇关于日期转换问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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