LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default datetimepicker finding the hours between two dates

Hello
Just like the subject says I am using two datetimepickers a start and end
and would like to know the hours between the two (or days). So far I have

Private Sub calcHours()
Dim totalHours As Integer
'totalHours = DateInitiatedDateTimePicker.Value.Day -
DateFinishedDateTimePicker.Value.Day
Dim startDate As DateTime = DateInitiatedDateTimePicker.Value
Dim finishDate As DateTime = DateFinishedDateTimePicker.Value
totalHours = startDate.Day + finishDate.Day
'totalHours = DateFinishedDateTimePicker.Value.Day -
DateInitiatedDateTimePicker.Value.Day
HoursTextBox.Text = totalHours
MessageBox.Show(totalHours)
End Sub

Not sure whether to add or subtract the dates. If I subtract then I always
get a 0.
If I add using the dates 1/15/2010 for start and 2/2/2010 for end I get a
value of 10.
This doesn't make sense to me for either hours or days.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTimePicker sarndt Excel Programming 2 December 13th 09 04:20 PM
DateTimePicker control problem Jac Tremblay[_4_] Excel Programming 0 December 13th 08 02:54 AM
Determining work hours between dates / hours Andrew Excel Worksheet Functions 3 July 30th 08 06:38 PM
dates to hours Champ Excel Discussion (Misc queries) 2 July 3rd 08 07:07 PM
DateTimePicker crazybass2 Excel Programming 3 January 11th 06 11:34 PM


All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"