Link to home
Start Free TrialLog in
Avatar of jrmcdona
jrmcdona

asked on

subtracting from the current date

I have a date value and I need to subract it from the current date(DateTime.Now). Which is a timespan value so therefore this calculation is not working.

MyTime = a datetime value from my database.

I need to subract:

NewTime = DateTime.Now - MyTime;

I cannot seem to figure out how to get this to work!

any help would be great!

thanks Jordan





Avatar of AaronReams
AaronReams

DateTime date2 = DateTime.Now;
DateTime date1 = MyTime;
TimeSpan diff1 = date2.Subtract(date1);
ASKER CERTIFIED SOLUTION
Avatar of AaronReams
AaronReams

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial