FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Conversi贸n varchar en datetime produjo valor fuera intervalo
Posts: 115
Joined: Fri Oct 14, 2005 07:10 PM
Conversi贸n varchar en datetime produjo valor fuera intervalo
Posted: Tue Dec 13, 2022 04:08 PM
Hola, estoy reconstruyendo mi base de datos despues de la visita de un Ramsonware y me est谩 dando este error que antes no sucedia.
Lo extra帽o es que si acceso la base de datos directamente en el PC donde est谩 el servidor, no sucede, sin embargo si lo hago a trav茅s de la red local se produce el error.
La BD est谩 en MSSQLEXPRESS.
Agradezco de antemano quien me pueda ayudar.


Application
===========
Path and name: C:\SIS\DesaFW\FactNew\FactNew.exe (32 bits)
Size: 5,706,240 bytes
Compiler version: Harbour 3.2.0dev (r2008190002)
FiveWin version: FWH 21.02
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 10.0, Build 22621

Time from start: 0 hours 0 mins 19 secs
Error occurred at: 13/12/2022, 12:32:46
Error description: (DOS Error -2147352567) WINOLE/1007 La conversi贸n del tipo de datos varchar en datetime produjo un valor fuera de intervalo. (0x80040E07): Microsoft OLE DB Driver for SQL Server
Args:
[ 1] = C UPDATE PAGBORR SET PgTipo = 'EF', PgFecha = '2022-12-13', PgHora = '12:32', PgFCobr = '2022-12-13', PgMonto = 100.00, PgSerie = '', PgBanco = '', PgPlaza = '', PgCuent = '' WHERE Id = 120

Stack Calls
===========
Called from: => TOLEAUTO:EXECUTE( 0 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => GRABACAJA( 3439 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => PRINTDOCTO( 3280 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => (b)INCAJABORR( 3258 )
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 179 )
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1781 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => SENDMESSAGE( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 433 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 1140 )
Called from: => DIALOGBOX( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => INCAJABORR( 3263 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => INGPAGO( 2364 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => (b)INIDIALOG( 1007 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 713 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 999 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1817 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2051 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => DIALOGBOX( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
Called from: C:\SIS\DesaFW\FactNew\BORRADOR.PRG => BORRADOR( 596 )
Called from: C:\SIS\DesaFW\FactNew\FACTNEW.PRG => (b)MAIN( 518 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 713 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 999 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1817 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2051 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1097 )
Called from: C:\SIS\DesaFW\FactNew\FACTNEW.PRG => MAIN( 542 )

System
======
CPU type: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz 2304 Mhz
Hardware memory: 7830 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Windows total applications running: 6
1 ,
2 , C:\WINDOWS\System32\SHELL32.dll
3 , C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.608_none_f0f1837
4 Conmutaci贸n de tareas, C:\SIS\DesaFW\FactNew\FactNew.exe
5 DDE Server Window, C:\WINDOWS\System32\OLE32.DLL
6 GDI+ Window (FactNew.exe), C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.22621.819_none_21dd7a56301966e
Esta es la instrucci贸n donde se produce el error :
Code (fw): Select all Collapse
cSql聽 聽 :=聽 "UPDATE PAGBORR SET "
cSql聽 聽 +=聽 "PgTipo = '" + aPAGBORR[nIndM, 1] + "', " 聽 聽 聽 聽 聽 聽 聽 聽聽 聽 聽 聽 聽 聽// PgTipo
cSql聽 聽 +=聽 "PgFecha = " 聽+ FW_ValToSQL(aPAGBORR[nIndM, 3]) + ", "聽 // PgFecha
cSql聽 聽 +=聽 "PgHora = '" + SUBSTR(TIME(),1,5) + "', " 聽 聽 聽 聽 聽 聽 聽 聽聽 聽 聽 聽 聽 聽// PgHora
cSql聽 聽 +=聽 "PgFCobr = " 聽+ FW_ValToSQL(aPAGBORR[nIndM, 3]) + ", " 聽 聽 聽// PgFCobr
cSql聽 聽 +=聽 "PgMonto = " 聽+ STR(aPAGBORR[nIndM, 2]) + ", " 聽 聽 聽聽 聽 聽 聽 // PgMonto
cSql聽 聽 +=聽 "PgSerie = '" + RTRIM(aPAGBORR[nIndM, 4]) + "', " 聽 聽 聽 聽聽 聽// PgSerie
cSql聽 聽 +=聽 "PgBanco = '" + RTRIM(aPAGBORR[nIndM, 5]) + "', " 聽 聽 聽 聽聽 聽// PgBanco
cSql聽 聽 +=聽 "PgPlaza = '" + RTRIM(aPAGBORR[nIndM, 6]) + "', " 聽 聽 聽 聽聽 聽// PgPlaza
cSql聽 聽 +=聽 "PgCuent = '" + RTRIM(aPAGBORR[nIndM, 7]) + "' " 聽 聽 聽 聽 聽 聽// PgCuent
cSql聽 聽 += "WHERE Id = " + STR(aPAGBORR[nIndM, 8]) 聽聽 聽 聽 聽 聽 聽 // Id
oCn:Execute( cSql )
Saludos,

Gonzalo

Puerto Montt - CHILE

FWH 22.12 - Harbour 3.2.0dev (r2008190002) - Borland/Embarcadero C++ 7.0(32-bit)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Conversi贸n varchar en datetime produjo valor fuera intervalo
Posted: Tue Dec 13, 2022 09:11 PM
Estimado Gonzalo,

Mira lo que responde chatGPT:
https://chat.openai.com/chat
Como se soluciona este error: La conversi贸n del tipo de datos varchar en datetime produjo un valor fuera de intervalo
Este error se produce cuando se intenta convertir un valor de tipo varchar (cadena de caracteres) en un valor de tipo datetime (fecha y hora), pero el valor en la cadena de caracteres no es una fecha y hora v谩lidas. Para solucionar este error, debe asegurarse de que la cadena de caracteres que est谩 intentando convertir contenga una fecha y hora v谩lidas en un formato reconocido por SQL Server. Por ejemplo, si la cadena de caracteres es '2022-12-13', debe asegurarse de que est谩 en el formato 'yyyy-mm-dd', donde yyyy es el a帽o con cuatro d铆gitos, mm es el mes con dos d铆gitos y dd es el d铆a con dos d铆gitos. Una vez que haya asegurado que la cadena de caracteres tiene una fecha y hora v谩lidas en un formato reconocido, puede intentar convertirla nuevamente en un valor de tipo datetime utilizando la funci贸n de conversi贸n de SQL Server adecuada, como CONVERT o TRY_CONVERT.
Puedes preguntarle varias veces lo mismo y te ir谩 dando distintos resultados, con ejemplos, etc:
Asegurarse de que el valor que se est谩 intentando convertir tenga un formato v谩lido para datetime. Por ejemplo, si se est谩 intentando convertir el valor '2022-12-13', asegurarse de que est茅 en el formato correcto, es decir, 'yyyy-mm-dd'.

Utilizar la funci贸n TRY_CONVERT en lugar de CONVERT para intentar realizar la conversi贸n. La funci贸n TRY_CONVERT intentar谩 realizar la conversi贸n, pero si no es posible, devolver谩 un valor NULL en lugar de generar un error.
Este error se produce cuando se intenta convertir un valor de tipo varchar a un tipo datetime y el valor del varchar no est谩 en un formato de fecha y hora v谩lido. Para solucionar este problema, se puede utilizar la funci贸n CONVERT de SQL junto con un formato de fecha y hora v谩lido para realizar la conversi贸n. Por ejemplo, si se quiere convertir el valor '2022-12-13' al tipo datetime, se podr铆a usar la siguiente consulta:

Copy code
SELECT CONVERT(datetime, '2022-12-13', 120)
En este caso, el formato de fecha y hora que se est谩 utilizando es el n煤mero 120, que indica que el valor a convertir est谩 en el formato 'YYYY-MM-DD'. Si el valor del varchar est谩 en un formato diferente, se deber谩 utilizar un formato de fecha y hora diferente en la funci贸n CONVERT para que la conversi贸n sea exitosa.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 115
Joined: Fri Oct 14, 2005 07:10 PM
Re: Conversi贸n varchar en datetime produjo valor fuera intervalo
Posted: Wed Dec 14, 2022 11:18 PM

Muchas gracias Antonio, resolv铆 el problema, faltaban algunos atributos que asignar a la base de dato.

Saludos,

Gonzalo

Puerto Montt - CHILE

FWH 22.12 - Harbour 3.2.0dev (r2008190002) - Borland/Embarcadero C++ 7.0(32-bit)

Continue the discussion