cfisher440
Well-known member
- Joined
- Oct 11, 2005
- Messages
- 73
- Programming Experience
- 1-3
In a nutshell, I need to add time values to a MS Access database in the format HH:mm (05:14)
The program is working for the most part, but if somebody could look at what I have below and offer me a solution I would appreciate it.
First the program will do this:
Dim strHDTimeLine As String() = Regex.Split(strHDLine71, " ")
Dim strHDTime(6) As String
strHDTime(0) = strHDTimeLine(58)
strHDTime(1) = strHDTimeLine(59)
strHDTime(2) = strHDTimeLine(60)
In this case strHDTime(0) = "05:49" then I convert the values to times.
Dim dates(6) As DateTime
dates(0) = FormatDateTime(CDate(strHDTime(0)), DateFormat.ShortTime)
dates(1) = FormatDateTime(CDate(strHDTime(1)), DateFormat.ShortTime)
dates(2) = FormatDateTime(CDate(strHDTime(2)), DateFormat.ShortTime)
Now dates(0) = #5:49:00 AM#
From there, I attempt to put these values in the database with my function call I made
AddDatabase(totHDRec, totHDAnsd, TotHDAbd, HDxfer, fHDrec, dates(0), dates(1), dates(2))
In the function (Don't worry about a1 - a5 those values have been established and add themselves to the database)
Public Sub AddDatabase(ByVal a1 As Int32, ByVal a2 As Int32, ByVal a3 As Int32, ByVal a4 As Int32, _
ByVal a5 As Int32, ByVal a6 As DateTime, ByVal a7 As DateTime, ByVal a8 As DateTime)
Dim newRow As DataRow = DsVRUB1.ACDSysSum.NewRow
newRow("TotalRecieved") = a1
newRow("TotalAnswered") = a2
newRow("TotalAbandoned") = a3
newRow("Transfered") = a4
newRow("FirstRecord") = a5
newRow("AvgTotTalk") = FormatDateTime(CDate(a6), DateFormat.ShortTime)
newRow("AvgTotAnsd") = FormatDateTime(CDate(a7), DateFormat.ShortTime)
newRow("AvgWork") = FormatDateTime(CDate(a8), DateFormat.ShortTime)
'newRow("AvgTotTalk") = a6.ToShortTimeString
'newRow("AvgTotAnsd") = a7.ToShortTimeString
'newRow("AvgWork") =
'newRow("AvgWork") = a8.ToShortTimeString
' dates(1)
'newRow("AvgWork") = dates(2)
Try
DsVRUB1.ACDSysSum.Rows.Add(newRow)
daVRUSys.Update(DsVRUB1, "ACDSysSum")
lblDone.Text = "Count of records Imported = " & x
x = x + 1
Catch ex As Exception
lblDone.Visible = False
lblDone.Text = ""
MsgBox("Error: " & ex.ToString, MsgBoxStyle.Critical, "ERROR IN Add to DB")
Finally
If conVRU.State = ConnectionState.Open Then
conVRU.Close()
End If
End Try
End Sub
Now a6 is equal to #1/21/2006 5:49:00 AM# {Date}
All the other values (that are not DateTime) are successfully being added to the database. My values set up in my MS Access database for the Times are as DateTime with a format of ShortTime. The values in the datset for those values (a6 - a8) are set as datetime. I have tried many ways of formatting the datetime as a short time value before adding it to the database to no avail.
In summary, the value coming into the function is the format #5:49:00 AM#. Before it attempts to add itself to the database, it is the format #1/21/2006 5:49:00 AM# {Date}. I need it to be in the format #05:49# as a short time.
Any help would be greatly appreciated.
The program is working for the most part, but if somebody could look at what I have below and offer me a solution I would appreciate it.
First the program will do this:
Dim strHDTimeLine As String() = Regex.Split(strHDLine71, " ")
Dim strHDTime(6) As String
strHDTime(0) = strHDTimeLine(58)
strHDTime(1) = strHDTimeLine(59)
strHDTime(2) = strHDTimeLine(60)
In this case strHDTime(0) = "05:49" then I convert the values to times.
Dim dates(6) As DateTime
dates(0) = FormatDateTime(CDate(strHDTime(0)), DateFormat.ShortTime)
dates(1) = FormatDateTime(CDate(strHDTime(1)), DateFormat.ShortTime)
dates(2) = FormatDateTime(CDate(strHDTime(2)), DateFormat.ShortTime)
Now dates(0) = #5:49:00 AM#
From there, I attempt to put these values in the database with my function call I made
AddDatabase(totHDRec, totHDAnsd, TotHDAbd, HDxfer, fHDrec, dates(0), dates(1), dates(2))
In the function (Don't worry about a1 - a5 those values have been established and add themselves to the database)
Public Sub AddDatabase(ByVal a1 As Int32, ByVal a2 As Int32, ByVal a3 As Int32, ByVal a4 As Int32, _
ByVal a5 As Int32, ByVal a6 As DateTime, ByVal a7 As DateTime, ByVal a8 As DateTime)
Dim newRow As DataRow = DsVRUB1.ACDSysSum.NewRow
newRow("TotalRecieved") = a1
newRow("TotalAnswered") = a2
newRow("TotalAbandoned") = a3
newRow("Transfered") = a4
newRow("FirstRecord") = a5
newRow("AvgTotTalk") = FormatDateTime(CDate(a6), DateFormat.ShortTime)
newRow("AvgTotAnsd") = FormatDateTime(CDate(a7), DateFormat.ShortTime)
newRow("AvgWork") = FormatDateTime(CDate(a8), DateFormat.ShortTime)
'newRow("AvgTotTalk") = a6.ToShortTimeString
'newRow("AvgTotAnsd") = a7.ToShortTimeString
'newRow("AvgWork") =
'newRow("AvgWork") = a8.ToShortTimeString
' dates(1)
'newRow("AvgWork") = dates(2)
Try
DsVRUB1.ACDSysSum.Rows.Add(newRow)
daVRUSys.Update(DsVRUB1, "ACDSysSum")
lblDone.Text = "Count of records Imported = " & x
x = x + 1
Catch ex As Exception
lblDone.Visible = False
lblDone.Text = ""
MsgBox("Error: " & ex.ToString, MsgBoxStyle.Critical, "ERROR IN Add to DB")
Finally
If conVRU.State = ConnectionState.Open Then
conVRU.Close()
End If
End Try
End Sub
Now a6 is equal to #1/21/2006 5:49:00 AM# {Date}
All the other values (that are not DateTime) are successfully being added to the database. My values set up in my MS Access database for the Times are as DateTime with a format of ShortTime. The values in the datset for those values (a6 - a8) are set as datetime. I have tried many ways of formatting the datetime as a short time value before adding it to the database to no avail.
In summary, the value coming into the function is the format #5:49:00 AM#. Before it attempts to add itself to the database, it is the format #1/21/2006 5:49:00 AM# {Date}. I need it to be in the format #05:49# as a short time.
Any help would be greatly appreciated.
Last edited: