Home » SQL & PL/SQL » SQL & PL/SQL » Date Calculation
Date Calculation [message #476340] Wed, 22 September 2010 12:46 Go to next message
coolguy01
Messages: 64
Registered: August 2006
Member
I need to verify if the current date is grater than the 15th of the current month. If its grater than the 15th of the current month i need to do an action or if else its lesser than 15th of the current month i need to do an other operation.
Re: Date Calculation [message #476342 is a reply to message #476340] Wed, 22 September 2010 12:48 Go to previous messageGo to next message
LKBrwn_DBA
Messages: 487
Registered: July 2003
Location: WPB, FL
Senior Member
Try:
SELECT TRUNC(SYSDATE,'MONTH')+14 FROM DUAL;

Razz
Re: Date Calculation [message #476343 is a reply to message #476342] Wed, 22 September 2010 12:55 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
You need to be more specific. Is this SQL, PL/SQL or something else?
SQL> select to_char(sysdate, 'dd-Mon-yyyy') from dual;

TO_CHAR(SYS
-----------
22-Sep-2010

SQL> select to_number(to_char(sysdate, 'dd')) day_of_month from dual;

DAY_OF_MONTH
------------
          22

SQL>
Re: Date Calculation [message #476347 is a reply to message #476343] Wed, 22 September 2010 13:08 Go to previous messageGo to next message
Michel Cadot
Messages: 67372
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select extract(day from sysdate) "day of the month" from dual;
day of the month
----------------
              22

Regards
Michel
icon14.gif  Re: Date Calculation [message #476880 is a reply to message #476340] Mon, 27 September 2010 02:05 Go to previous messageGo to next message
bnrvkv
Messages: 2
Registered: October 2009
Junior Member
SELECT
CASE
WHEN SYSDATE > TRUNC(SYSDATE,'MONTH')+14 THEN
<<INVOKE THE FUNCTION THAT PERFORM FIRST SET OF OPERATION>>
ELSE
<<INVOKE THE FUNCTION THAT PERFORM SECOND SET OF OPERATION>>
END date_check
FROM dual;
Re: Date Calculation [message #476881 is a reply to message #476880] Mon, 27 September 2010 02:13 Go to previous message
Michel Cadot
Messages: 67372
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Welcome to the forum.
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel
Previous Topic: SQL to get all employees under same manager
Next Topic: Apportioning Query
Goto Forum:
  


Current Time: Tue Sep 29 10:13:26 CDT 2020