A type for Date only in C# - why is there no Date type?

后端 未结 13 1889
暗喜
暗喜 2020-11-28 10:23

In our C# project we have the need for representing a date without a time. I know of the existence of the DateTime, however, it incorporates a time of day as well. I

13条回答
  •  -上瘾入骨i
    2020-11-28 10:55

    If you need to run date comparisons then use

    yourdatetime.Date;
    

    If you are displaying to the screen use

    yourdatetime.ToShortDateString();
    

提交回复
热议问题