SQL - restar un dia a una fecha

 
Vista:

restar un dia a una fecha

Publicado por Oscar (39 intervenciones) el 20/02/2012 15:35:15
Hola
Necesito restar solo un dia a un campo datetime, lo intento hacer solo restandonde uno (-1) pero me sale el error_
INT is incompatible with DATETIME
Alguien sabe con que funcion debo hacer esta resta?
Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

restar un dia a una fecha

Publicado por Leopoldotaylhardat (93 intervenciones) el 20/02/2012 16:06:22
Saludos...
En Transact-SQL (Sybase, SqlServer) es dateadd...
del manual:
DATEADD ( date-part, numeric-expr, date-expr ) Returns the date produced by adding the specified number of the specified date parts to the date. The numeric_expression can be any numeric type; the value is truncated to an integer. For example, the following statement displays 1995-11-02 00:00:00.000.

SELECT dateadd( month, 102, '1987/05/02' )
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

restar un dia a una fecha

Publicado por Rogelio (1 intervención) el 10/10/2014 17:42:55
Exceletene respuesta Leopoldotaylhardat, me funcionó perfecto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar