比较两个日期时间 - 无需小时和第二 [英] Compare two datetimes - without hour and second

查看:101
本文介绍了比较两个日期时间 - 无需小时和第二的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题状态,什么是要比较的日期时间的没有时间和秒的最好方法是什么?

As the title states, what's the best way to compare to DateTime's without hours and seconds?

我不希望我的日期转换为字符串,一解决方案像

I don't want to convert my dates to string, and a solution like

DateTime.Now.Year == last.Year&放大器;&安培;
DateTime.Now.Month == last.Month&放大器;&安培;
DateTime.Now.Day == last.Day

真的是太丑陋。

编辑:哦,我的上帝,多么愚蠢,我觉得。当然,你可以使用日期属性。

Oh my god, how silly I feel. Of course you can use the Date property.

另一个问题:什么是比较日期时间的年,月,日,时,分的最佳方式,但不?秒

"Another question": What is the best way to compare DateTime's with Year, Month, Day, Hour, Minute, but not seconds?

感谢

推荐答案

是这样的:你在做什么找谁?

Is this: what you're looking for?

DateTime.Now.Date

这篇关于比较两个日期时间 - 无需小时和第二的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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