datetime differences

  • Thread starter Thread starter SenthilVel
  • Start date Start date
S

SenthilVel

HI

how to get the differences in 2 given dates??

supposse if i ahve 2 dates , DATEa, and current datetime.

how can i find if the DATEa is less then 3 hrs from the current datetime ???


,,,,
Senthil
 
HI

how to get the differences in 2 given dates??

supposse if i ahve 2 dates , DATEa, and current datetime.

how can i find if the DATEa is less then 3 hrs from the current datetime ???


,,,,
Senthil

TimeSpan diff = DateTime.Now.Subtract (dateA);
if (diff.TotalHours < 3)
{
// do cool stuff
}
 
Hello,
Please see the following code snippet for the task you want to do.

//Assign dateA
TimeSpan timeSpan = DateTime.Now.Subtract(dateA);

Use timeSpan.TotalHours to get total hours

Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
 
Back
Top