DatetimeTs1 =Datetime. Parse ("2008-6-1");
DatetimeTs2 =Datetime. Parse (");
TimespanTS = ts1.subtract (ts2). duration ();
// Response. Write (TS. Days. tostring () + "day" + ts. Hours. tostring () + "hour"
// + Ts. Minutes. tostring () + "Minute" + ts. Seconds. tostring () + "second ");
Response. Write (TS. totalhours. tostring ());
Note:
1. The datetime Value Type represents a specific date time between 00:00:00 on January 1, January 1, 0001 AD and on January 1, December 31, 9999 AD. Therefore, you can use the datetime value type to describe anyTime. A datetime value represents a specific time.
2. the timespan value contains many attributes and methods for accessing or processing a timespan value.
the following list covers a part of the list:
Add: add to another timespan value.
days: returns the timespan value calculated by the number of days.
Duration: obtains the absolute value of timespan.
hours: returns the hourly timespan value
milliseconds: returns the timespan value in milliseconds.
minutes: returns the timespan value calculated in minutes.
negate: returns the opposite number of the current instance.
seconds: returns the timespan value calculated in seconds.
subtract: Subtract another timespan value from it.
ticks: the number of tick values returned for timespan.
totaldays: returns the number of days indicated by the timespan value.
totalhours: returns the number of hours represented by the timespan value.
totalmilliseconds: returns the number of milliseconds represented by the timespan value.
totalminutes: returns the number of minutes represented by the timespan value.
totalseconds: returns the number of seconds represented by the timespan value.