Consulta del ultimo dia del mes

SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) as FechaUltimoDM

4 Responses

Saludos Edson. En qué motor de BD usas ese query?
Buenas Marco lo uso en SQL SERVER 2012
A partir de la versión 2012 puedes utilizar la función EOMONTH:

SELECT EOMONTH (GETDATE()) AS FechaUltimoDiaMes;
Oracle:
select add_months(trunc(sysdate,'MM'), 1)-1 from dual;
select last_day(trunc(sysdate)) from dual;

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.