Return to Snippet

Revision: 30414
at August 14, 2010 00:29 by derebus


Updated Code
SELECT DATEADD(mm, DATEDIFF(mm,0,GETDATE()), 0),'El primer dia del mes'
UNION
SELECT DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,GETDATE()  )+1, 0)),'El Ultimo dia del mes'
UNION
SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0),'El Lunes de la semana actual'
UNION
SELECT DATEADD(yy, DATEDIFF(yy,0,GETDATE()), 0),'Primer dia del año'
UNION
SELECT DATEADD(ms,-3,DATEADD(mm, DATEDIFF(mm,0,GETDATE()  ), 0)),'Ultimo dia del mes anterior'
UNION
SELECT DATEADD(ms,-3,DATEADD(yy, DATEDIFF(yy,0,GETDATE() ), 0)),'Ultimo dia del año anterior'
UNION
SELECT DATEADD(wk, DATEDIFF(wk,0,DATEADD(dd,6-DATEPART(DAY,GETDATE()),GETDATE())), 0),'Primer lunes del mes'
UNION
SELECT DATEADD(mm, -1, DATEADD(mm, DATEDIFF(mm,0,GETDATE()), 0)),'Primer dia del mes anterior'

Revision: 30413
at August 13, 2010 09:04 by derebus


Initial Code
SELECT DATEADD(mm, DATEDIFF(mm,0,getdate()), 0),'El primer dia del mes'
UNION
SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate()  )+1, 0)),'El Ultimo dia del mes'
UNION
SELECT DATEADD(wk, DATEDIFF(wk,0,getdate()), 0),'El Lunes de la semana actual'
UNION
SELECT DATEADD(yy, DATEDIFF(yy,0,getdate()), 0),'Primer dia del año'
UNION
SELECT dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()  ), 0)),'Ultimo dia del mes anterior'
UNION
SELECT dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate() ), 0)),'Ultimo dia del año anterior'
UNION
SELECT DATEADD(wk, DATEDIFF(wk,0,dateadd(dd,6-datepart(day,getdate()),getdate())), 0),'Primer lunes del mes'

Initial URL
http://www.chocolim.com/?p=107

Initial Description
El primer dia del mes, El Ultimo dia del mes, El Lunes de la semana actual, Primer dia del año, Ultimo dia del mes anterior, Ultimo dia del año anterior, Primer lunes del mes, Primer dia del mes anterior

Initial Title
Getting Dates in Sql Server 2

Initial Tags

                                

Initial Language
SQL