Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use the <a href="http://msdn.microsoft.com/en-us/library/system.datetime.op_subtraction.aspx" rel="noreferrer">subtraction operator</a> on the two instances of <a href="http://msdn.microsoft.com/en-us/library/system.datetime.aspx" rel="noreferrer"><code>DateTime</code></a> (or <a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx" rel="noreferrer"><code>DateTimeOffset</code></a>, as it has the same <a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.op_subtraction.aspx" rel="noreferrer">subtraction operator</a>, and it is the <a href="http://msdn.microsoft.com/en-us/library/bb384267.aspx" rel="noreferrer">recommended structure to use for date values in .NET</a>) to get a <a href="http://msdn.microsoft.com/en-us/library/system.timespan.aspx" rel="noreferrer"><code>TimeSpan</code></a> instance.</p> <p>Once you have that, you can call the <a href="http://msdn.microsoft.com/en-us/library/system.timespan.days.aspx" rel="noreferrer"><code>Days</code> property</a> to get the number of whole days that the <code>TimeSpan</code> represents.</p> <p>If you want the number of whole and fractional days, then look at the <a href="http://msdn.microsoft.com/en-us/library/system.timespan.totaldays.aspx" rel="noreferrer"><code>TotalDays</code> property</a>.</p> <p>In your specific case, it seems that you want to add 1 to whatever value the <code>Days</code> property returns, as your custom calculation indicates that for two <code>DateTime</code> instances that represent the same value, the result is 1.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload