By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

Crazy trouble on date

P: n/a
Hi everyone

i got a problem on date, it is...

1, i get the date from calendar component

2, compare today and selected date is equal (compare method)

3 count the number of day between this 2 date

but i cannot find any method to count the number of day between this 2 date

just like...2006/4/5 - 2006/4/1....i will get the result 4

anyone know how to do subtrust the date???

thx a lot
Apr 22 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Budd,
1, i get the date from calendar component Use the SelectedDate property, or the SelectedDates property, depending upon
which SelectionMode you're using. This returns a DateTime.
2, compare today and selected date is equal (compare method) Assuming that you only need to compare to the day, use the DateTime.Subtract
method. The DateTime.Subtract method is an instance method of the DateTime
structure, and takes another DateTime as an argument. It returns a TimeSpan,
indicating the difference between the 2 Dates. The TotalDays member of the
TimeSpan is a double which indicates the total number of days in the
TimeSpan. Since you only want to compare to the Day, you need to eliminate
fractional days from the value. This is easily done by casting the value as
a long.

If the result is negative, the second date is greater than the date
subtracting it, by that many days. If you just need to know if the dates are
the same day, all you need to do is compare the long integer result to 0.
3 count the number of day between this 2 date Same deal as number 2. If you only need to know the number of days, use
Math.Abs to get rid of any negativity.
anyone know how to do subtrust the date??? Nah, sorry, don't know that one.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Budd" <bu**@add.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl... Hi everyone

i got a problem on date, it is...

1, i get the date from calendar component

2, compare today and selected date is equal (compare method)

3 count the number of day between this 2 date

but i cannot find any method to count the number of day between this 2
date

just like...2006/4/5 - 2006/4/1....i will get the result 4

anyone know how to do subtrust the date???

thx a lot

Apr 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.