Study Note 1

Source: Internet
Author: User
I just read this article on msdn. Article

Determining the span between two dates

Example
Datetime olddate = new datetime (2002,7, 15); datetime newdate = datetime. now; // difference in days, hours, and minutes. timespan Ts = newdate-olddate; // difference in days.int differenceindays = ts. days; console. writeline ("difference in days: {0}", differenceindays );


After reading some examples, I found that new is required for everything: (, It's really troublesome .)
The spacing during the day can be obtained in this way, which is troublesome.
Int differenceindays = ts. Days; returns the number of days that are different between two days,
Int diffhour = ts. hours; the result is not the total hours differenceindays * 24 in the two-day period, but the comparison of the time directly without considering the date. Now it is, the result is 18. Strange.
The same is true in minutes ~~

~~ Make a mark ~~ I will try again tomorrow to find the answer to my questions.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.