Date in SQL ORACLE

1

How do I apply a function in SQL ORACLE that just brings me records from the current month? Note: I have a date column in date format (eg 13/13/18).

In the sql server I applied the function below and worked perfectly:

DAT_REFERENCIA>= DATEADD(MM,DATEDIFF(MM,0,GETDATE())-0,0)
    
asked by anonymous 13.09.2018 / 19:32

2 answers

2

You can use WHERE like this:

WHERE trunc( DAT_REFERENCIA, 'MM' ) = trunc( sysdate, 'MM' )

It will get the current date of sysdate (as getdate() on sql-server )

EDIT: To get the current month and the previous month, you can use between :

WHERE DAT_REFERENCIA BETWEEN  add_months(trunc(sysdate,'MM'),-1) AND SYSDATE
    
13.09.2018 / 19:42
0

Friend, use the EXTRACT function for the command that takes the current date in Oracle that is sysdate . Here's an example below:

Select extract(month from sysdate) as MES_ATUAL from dual ; 
    
13.09.2018 / 19:39