Error converting the data type varchar to datetime

0

My problem is I want to add three dates that are in datetime format in sql.

these date variables are in an SP and when sending the information manually in sql server:

exec spInsertaCargoCobranzaMV '00024','002',21554,1,0,500.00,'5-19-2017',1,-6,0,'12-12-2017','12-12-2018','SIMBANK','a3addaffedc7068e','20.6909728','-100.4432175'

I get the following error

Error al convertir el tipo de datos varchar a datetime.

Also try to execute the sp as follows:

exec spInsertaCargoCobranzaMV '00024','002',21554,1,0,500.00,'5/19/2017',1,-6,0,'12/12/2017','12/12/2018','SIMBANK','a3addaffedc7068e','20.6909728','-100.4432175'

Also in this other way:

exec spInsertaCargoCobranzaMV '00024','002',21554,1,0,500.00,'5-19-2017 12:00:00 AM',1,-6,0,'12-12-2017 12:00:00 AM','12-12-2018 12:00:00 AM','SIMBANK','a3addaffedc7068e','20.6909728','-100.4432175'
    
asked by David 15.11.2017 в 01:25
source

1 answer

2

If you use the YYYYMMDD format, you should not have problems where the interpretation of the date depends on the settings DATEFORMAT , LANGUAGE , etc .:

'20170519'

For more information about the date formats you can use safely:

answered by 15.11.2017 / 01:38
source