Funciones de fecha

09/12/2004 - 15:45 por Laura | Informe spam
¿Existe alguna función que retorne la cantidad de días que
tiene un mes, pasandole una fecha como parámetro?
Gracias

Preguntas similare

Leer las respuestas

#1 Gustavo Larriera [MVP]
09/12/2004 - 15:58 | Informe spam
USE tempdb
GO

argumento
CREATE FUNCTION ufn_daysInMonth(@argFecha DATETIME)
RETURNS INTEGER
AS
BEGIN
RETURN DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(@argFecha), @argFecha)) - 1)
END
GO

SELECT dbo.ufn_daysInMonth(getdate())

Gustavo Larriera, MVP
Uruguay LatAm
http://sqljunkies.com/weblog/gux/
Este mensaje se proporciona "COMO ESTA" sin garantias y no otorga ningun
derecho / This posting is provided "AS IS" with no warranties, and confers
no rights.
"Laura" wrote in message
news:1d5001c4ddfd$c1c739a0$
¿Existe alguna función que retorne la cantidad de días que
tiene un mes, pasandole una fecha como parámetro?
Gracias
Respuesta Responder a este mensaje
#2 Laura
09/12/2004 - 16:02 | Informe spam
Muchas gracias, Gustavo


USE tempdb
GO



fecha usada como
argumento
CREATE FUNCTION ufn_daysInMonth(@argFecha DATETIME)
RETURNS INTEGER
AS
BEGIN
RETURN DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(@argFecha),


@argFecha)) - 1)
END
GO

SELECT dbo.ufn_daysInMonth(getdate())

Gustavo Larriera, MVP
Uruguay LatAm
http://sqljunkies.com/weblog/gux/
Este mensaje se proporciona "COMO ESTA" sin garantias y


no otorga ningun
derecho / This posting is provided "AS IS" with no


warranties, and confers
no rights.
"Laura" wrote in


message
news:1d5001c4ddfd$c1c739a0$
¿Existe alguna función que retorne la cantidad de días que
tiene un mes, pasandole una fecha como parámetro?
Gracias


.

email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida