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