![]() Instead, it returns a new DateTime whose value is the result of this operation. This method does not change the value of this DateTime. For example, to subtract two months from the current date, call the AddMonths(Int32) method with a value of -2. To subtract a particular time interval from the current instance, call the method that adds that time interval to the current date, and supply a negative value as the method argument. To determine the time interval between two dates, call the Subtract(DateTime) method. The Subtract(TimeSpan) method returns the date that is a specified time interval difference from the current instance. Otherwise, the result will include the difference between time zones. Before subtracting DateTime objects, ensure that the objects represent times in the same time zone. The Subtract(DateTime) method does not consider the value of the Kind property of the two DateTime values when performing the subtraction. ![]() That is, the value of all of its non-zero properties (such as Days or Ticks) is negative. If the date and time of the current instance is earlier than value, the method returns a TimeSpan object that represents a negative time span. To subtract a time interval from the current instance, call the Subtract(TimeSpan) method. The Subtract(DateTime) method determines the difference between two dates. ' diff2 gets 55 days 4 hours and 20 minutes.ĭiff2 = _Subtraction(date2, date3)ĭate5 = _Subtraction(date1, diff2) ' diff1 gets 185 days, 14 hours, and 47 minutes. System.TimeSpan diff1 = date2.Subtract(date1) diff2 gets 55 days 4 hours and 20 minutes. System::DateTime date4 = date3.Subtract( diff1 ) System::TimeSpan diff1 = date2.Subtract( date1 ) diff1 gets 185 days, 14 hours, and 47 minutes. The following example demonstrates the Subtract method and the subtraction operator. The result is less than DateTime.MinValue or greater than DateTime.MaxValue.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |