Playgrounds
Snippets
Developers
Compiler
All
ActionScript
Ajax
AngularJS
Apache
AppleScript
ASP.NET
Bash
C
C#
C++
Coffee
CoffeeScript
ColdFusion
Command
CSS
Delphi
Django
ES6
GLSL
Grunt
Gulp
HAML
Haskell
HTML
iOS
Jade
Java
JavaScript
jQuery
JSX
Less
LUA
MDX
MySQL
Objective
Other
Pascal
Perl
PHP
Plain text
PowerShell
Processing
Progress
Prolog
Pseudocode
Python
Rails
RegExr
Ruby
SASS
Scala
Scheme
SCSS
SmallBASIC
Smarty
SQL
Stylus
SVG
Swift
TypeScript
VHDL
X++
XHTML
XML
Xojo
XSLT
New snippet
New playground
Sign up
Login
Upload
Playgrounds
Snippets
Developers
Sign up
Login
Consulta del ultimo dia del mes
SQL
by
Edson Martinez
22nd February 2015
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?
0
Reply?
Marco Piñero
9 years ago
Buenas Marco lo uso en SQL SERVER 2012
0
Reply?
Edson Martinez
9 years ago
A partir de la versión 2012 puedes utilizar la función EOMONTH:
SELECT EOMONTH (GETDATE()) AS FechaUltimoDiaMes;
0
Reply?
LS
Laurence Saavedra
9 years ago
Oracle:
select add_months(trunc(sysdate,'MM'), 1)-1 from dual;
select last_day(trunc(sysdate)) from dual;
0
Reply?
RR
Ruben Rosado
9 years ago
Write a comment
Send 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.
4 Responses
SELECT EOMONTH (GETDATE()) AS FechaUltimoDiaMes;
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.