another question, I am trying to do some calculations with dates, but without much success...
I would like a use to be able to enter a start date, and an end date, and the application works out how many weeks that is.
the maths would be (end date - start date) / 7, as I am sure yo canwork out, but I am not sure how calculations are performed on dates...
thanks in advance for help
Patrick
Here is an article about subtracting a date from another -http://www.dotnetspider.com/kb/Article552.aspx
Arithmetic between 2 dates creates a TimeSpan object.
TimeSpan ts = date1 - date2;
int weeks = ts.Days / 7;
Hi Bob,
does using a DatePicker make any difference to what you have said? Iget an error saying that it can't convert a doublt to a timespan...thought if I had a date picker in there, that would limit the dateformat that can be entered, making the maths easier..
thanks
Patrick
As long as the DatePicket is returning a valid DateTime object then it shouldn't matter.
Post the piece of code where you are doing the arithmetic.
I have it now actually. thanks foryour help. :D I have another question thought hat I am just about topost... thanks for your help!
0 comments:
Post a Comment