Solved

How do I check for first and last day of month in Oracle

Posted on 2014-11-26
2
245 Views
Last Modified: 2014-11-27
Experts,

Does anyone know the syntax for testing for the first and last day of month in Oracle?
0
Comment
Question by:morinia
2 Comments
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 40467671
First day of the current month at midnight:

trunc(sysdate, 'MM')

Last day of the current month current time of day:

last_day(sysdate)

Last day of the current month midnight:

last_day(trunc(sysdate))

Last day of the current month at end of day:

last_day(trunc(sysdate)) + (84399/86400)
0
 
LVL 22

Accepted Solution

by:
Helena Marková earned 250 total points
ID: 40468481
As an addition to the complex johnsone's answer you can read about datetime format elements:
https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements004.htm#CDEHIFJA
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now