EDN Admin
Well-known member
Hi,
I am working on a vb.net project that tracks time. The due date needs to be calculated based on the start date + 8 hrs. The addition of 8 hrs is based on the work hours.If a person starts the task by 3:00 PM in evening, then the due date and time for him
must be calculated by adding 8 hrs based on working hours (09:00 - 18:00).
So if the person starts the task by 17Nov2012 3:00 PM in evening the due date for that task must be next day 18Nov2012 02:00 PM.
I got the below code from one of my thread and is for Access VBA. I tried to use the same code in the vb.net application but its throwing cast error that conversion from string to date is not valid.<br/>
Below is code that i am using<br/>
<pre class="prettyprint lang-vb Private Sub cmbStatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbStatus.SelectedIndexChanged
Dim dtStart As Date
If cmbStatus.SelectedIndex = 2 Then
dtStart = "08/11/2012 16:58:18"
Debug.Print(getEndTime(dtStart))
ElseIf cmbStatus.SelectedItem = "Closed" Then
txtCompletedDate.Text = Format(Now, "dd MMMM yyyy HH:mm")
End If
End Sub
Public Function getEndTime(ByVal startTime As Date) As Date
Dim dt As Date
dt = startTime + TimeSerial(8, 0, 0)
If dt > Int(startTime) + TimeSerial(18, 0, 0) Then
dt = startTime + TimeSerial(6 + 9 + 8, 0, 0)
End If
getEndTime = dt
End Function[/code]
I have attached the screenshot for your reference. Also i need both the date and time to be displayed in the enddate.
<img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/195662
<
Can you help me in this...
Thanks you and Kind Regards,
Karthik Venkatraman
<hr class="sig Thanks you and Kind Regards, Karthik Venkatraman
View the full article
I am working on a vb.net project that tracks time. The due date needs to be calculated based on the start date + 8 hrs. The addition of 8 hrs is based on the work hours.If a person starts the task by 3:00 PM in evening, then the due date and time for him
must be calculated by adding 8 hrs based on working hours (09:00 - 18:00).
So if the person starts the task by 17Nov2012 3:00 PM in evening the due date for that task must be next day 18Nov2012 02:00 PM.
I got the below code from one of my thread and is for Access VBA. I tried to use the same code in the vb.net application but its throwing cast error that conversion from string to date is not valid.<br/>
Below is code that i am using<br/>
<pre class="prettyprint lang-vb Private Sub cmbStatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbStatus.SelectedIndexChanged
Dim dtStart As Date
If cmbStatus.SelectedIndex = 2 Then
dtStart = "08/11/2012 16:58:18"
Debug.Print(getEndTime(dtStart))
ElseIf cmbStatus.SelectedItem = "Closed" Then
txtCompletedDate.Text = Format(Now, "dd MMMM yyyy HH:mm")
End If
End Sub
Public Function getEndTime(ByVal startTime As Date) As Date
Dim dt As Date
dt = startTime + TimeSerial(8, 0, 0)
If dt > Int(startTime) + TimeSerial(18, 0, 0) Then
dt = startTime + TimeSerial(6 + 9 + 8, 0, 0)
End If
getEndTime = dt
End Function[/code]
I have attached the screenshot for your reference. Also i need both the date and time to be displayed in the enddate.
<img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/195662
<
Can you help me in this...
Thanks you and Kind Regards,
Karthik Venkatraman
<hr class="sig Thanks you and Kind Regards, Karthik Venkatraman
View the full article