hi,
1-how can i do multiselect in calendar.
2-how many days between 2 dates? how can u calculate it?
example :
10/10/2006 - 12/10/2006 there is 1 day between those 2 dates.
thanks
hi,
1-how can i do multiselect in calendar.
2-how many days between 2 dates? how can u calculate it?
example :
10/10/2006 - 12/10/2006 there is 1 day between those 2 dates.
thanks
Short answer: handle the two problems separately.
For the day-count question (date arithmetic) the reliable rules are:
.Date so time-of-day does not alter the result..Days.Example VB (parsing with a known format to avoid mm/dd vs dd/mm ambiguity):
Dim d1 As DateTime = DateTime.ParseExact("10/10/2006", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim d2 As DateTime = DateTime.ParseExact("12/10/2006", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim diffDays As Integer = Math.Abs((d2.Date - d1.Date).Days) ' absolute difference in days
Dim daysBetweenExclusive As Integer = Math.Max(0, diffDays - 1) ' days strictly between the two dates
Dim inclusiveCount As Integer = diffDays + 1 ' count both endpoints This builds on 's TimeSpan idea and on 's point about whether endpoints are counted.
For multiselect on an ASP.NET WebForms Calendar: the control does not provide a simple, built-in multi-click UI for end users. A common, robust pattern is:
Minimal event skeleton (VB):
' initialize
ViewState("SelectedDates") = New List(Of Date)()
' SelectionChanged: toggle the clicked date in the list
' DayRender: if date in list then add CSS class to e.Cell Notes: always parse user input with a fixed format or culture, use .Date to strip times, and choose a client-side approach if you need many selections or better responsiveness.
Jump to Post— waynespangler 63Actually there are 61 days between those two dates.
Dim date1 As Date = #10/10/2006# Dim date2 As Date = #12/10/2006# Dim ts As TimeSpan = date2.Subtract(date1) Label1.Text = ts.TotalDays.ToStringThis is mm/dd/yy. If dd/mm/yy then date difference is 2 days.
Don't know about the calender …
Jump to Post— waynespangler 63Yea, same agrument I get from the wife. Next weekend is not the coming weekend but the one following. To me the next weekend is the one that is coming up.
Actually there are 61 days between those two dates.
Dim date1 As Date = #10/10/2006#
Dim date2 As Date = #12/10/2006#
Dim ts As TimeSpan = date2.Subtract(date1)
Label1.Text = ts.TotalDays.ToString This is mm/dd/yy. If dd/mm/yy then date difference is 2 days.
Don't know about the calender control.
hi,
thank you very much for your help
Actually there are 61 days between those two dates.
Dim date1 As Date = #10/10/2006# Dim date2 As Date = #12/10/2006# Dim ts As TimeSpan = date2.Subtract(date1) Label1.Text = ts.TotalDays.ToStringThis is mm/dd/yy. If dd/mm/yy then date difference is 2 days.
Don't know about the calender control.
Depends on what was meant by "how many days between two dates"
in dd/mm/yy format, there is technically "1" day between those two dates. Monday Oct 16 2006 to Wednesday Oct 18 2006, the day of Tuesday Oct 15 2006 would be the "1" day "between" those two dates.
Just all depends on what the original meaning was :)
Not sure of the actual code, but would be something like
date2.subtract(date1)
Label1.Text = ts.TotalDays.ToString (-2) <hehe, like i said, thats probably not it but the concept is there>
The (-2) part (yes i know, not correct probably) would take away 2 from the resulting answer to account for the beginning date and ending date. Again, this is only if you wanted to find out the actual number of days BETWEEN two dates (not counting those days)
Yea, same agrument I get from the wife. Next weekend is not the coming weekend but the one following. To me the next weekend is the one that is coming up.
Yea, same agrument I get from the wife. Next weekend is not the coming weekend but the one following. To me the next weekend is the one that is coming up.
My daughter is the same way. WOMEN! :mrgreen:
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.