I'm trying to make a program that will do some queries on a SQL Server, for some reason the code is having strange behavior, since it will create different date values on 2 of my computers.
This is the part of code behaving weird.
Query += " dbo.MensajesProcesados.SentDateTime BETWEEN CONVERT(VARCHAR, '" + FechaInicio.Value.ToUniversalTime().ToShortDateString() + "', 103) AND CONVERT(VARCHAR, '" + FechaFin.Value.ToUniversalTime().ToShortDateString() + "', 103)";
in 1st computer(working) gives me:
BETWEEN CONVERT(VARCHAR, '5/18/2015', 103) AND CONVERT(VARCHAR, '5/19/2015', 103)
and the second computer which is not working:
BETWEEN CONVERT(VARCHAR, '17/05/2015',103) AND CONVERT(VARCHAR, '19/05/2015',103)
This one is not working and will output me the following error
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Please, any help would be great!