4
I need select to return all the rows that were inserted in July 2010, as shown in the example, regardless of the day. How to return this query?
SELECT * FROM FRCAST
WHERE DATA_ID = TO_CHAR('07-2010', 'mm-yyyy');
4
I need select to return all the rows that were inserted in July 2010, as shown in the example, regardless of the day. How to return this query?
SELECT * FROM FRCAST
WHERE DATA_ID = TO_CHAR('07-2010', 'mm-yyyy');
6
You can use the function EXTRACT to test pieces of a date. Your query would look like this:
SELECT * FROM FRCAST
WHERE extract(month from DATA_ID) = 7 and extract (year from DATA_ID) = 2010;
1
You can also use the BETWEEN
:
SELECT * FROM FRCAST
WHERE DATA_ID between
TO_DATE('01/07/2010','DD/MM/YYYY') and
TO_DATE('31/07/2010 23:59:59','DD/MM/YYYY HH24:mi:ss');
0
To make this query, you can do as follows:
SELECT * FROM FRCAST
WHERE TO_CHAR(DATA_ID,'MM-YYYY')='07-2010';
References:
How to select Rows for a specific Month
TO_CHAR (datetime)
0
SELECT * FROM FRCAST
WHERE TO_CHAR(DATA_ID, 'mm-yyyy') ='07-2010'
Browser other questions tagged sql oracle
You are not signed in. Login or sign up in order to post.
That’s nice... I hadn’t thought of a solution to include the whole month without using
BETWEEN
. Take a +1– Daniel
Leave my answer as an alternative below, but Giuliana’s answer is more elegant and readable.
– George Wurthmann