Hello people im new on this, but im going to try to explain my self as well as possible.
Im working with Vb.net code.
I'm having this trouble, i have a datagrid in wich i add a colum wich calculates the time that a "ticket" has been in the system. The calculation function is called when the datagrid is been loaded.
Im having troubles when im trying to use the system in another machine that doesnt have Vstudio.
the page give me this error, and i try to change the var type to string and it doesnt work either.
CAST FROM STRING "31/03/2006" TO TYPE "DATE" IS NOT VALID
this is the code im using
Private Sub calcula_duracion(ByVal estado_sol As String)
Dim i As Integer
Dim ahora, entonces As DateTime
Dim tempdate1, tempdate2, tempdate3 As DateTime
Dim dias, horas, minutos, segundos, result As String
For i = 0 To dsconsulta.Tables(0).Rows.Count - 1
If estado_sol = "Pendiente" Or estado_sol = "Eliminada" Then
ahora = Now
ElseIf estado_sol = "Aceptada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_aceptacion")
ElseIf estado_sol = "Rechazada" Or estado_sol = "Solucionada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_solucion")
ElseIf estado_sol = "Aceptada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_aceptacion")
End If
lbltot.Text = dsconsulta.Tables(0).Rows.Count
entonces = dsconsulta.Tables(0).Rows(i).Item("fec_creacion")
tempdate1 = Format(entonces, "dd/MM/yyyy")
tempdate3 = Format(ahora, "dd/MM/yyyy")
tempdate2 = Format(ahora, "HH:mm")
If tempdate2 < CDate("8:00AM") Then
ahora = tempdate3 + " " + CDate("8:00AM")
ElseIf tempdate2 > CDate("6:00PM") Then
ahora = tempdate3 + " " + CDate("8:00AM")
ahora = ahora.AddDays(1)
End If
If DateDiff(DateInterval.Day, tempdate1, tempdate3) > 0 Then
dias = DateDiff(DateInterval.Day, tempdate1, tempdate3)
ahora = ahora.AddDays(-dias)
If DateDiff(DateInterval.Hour, entonces, ahora) < 0 Then
horas = DateDiff(DateInterval.Hour, ahora, entonces)
entonces = entonces.AddHours(-horas)
Else
horas = DateDiff(DateInterval.Hour, entonces, ahora)
ahora = ahora.AddHours(-horas)
End If
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Hour, entonces, ahora) > 0 Then
dias = "0"
horas = DateDiff(DateInterval.Hour, entonces, ahora)
ahora = ahora.AddHours(-horas)
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Minute, entonces, ahora) > 0 Then
dias = "0"
horas = "00"
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Second, entonces, ahora) > 0 Then
dias = "0"
horas = "00"
minutos = "00"
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
Else
result = "0d 00:00:00"
End If
dsconsulta.Tables(0).Rows(i).Item("Duracion") = result
Next
End Sub
tnx for ur time and help
I see that you are using a DD/MM/YYYY format for your date. Is it possible that the Regional settings of the new machine have a different date format?i've check that out and in the deploy machine it works fine because i have there visual studio and the sql server, but when i move the application to a network where the server is in a different pc that the one who has the IIS it doesnt work, and the IIS pc has the same regional settings that the deploy machine??
tnx
0 comments:
Post a Comment