Home » SQL & PL/SQL » SQL & PL/SQL » DATE CONVERSION
DATE CONVERSION [message #22823] Thu, 31 October 2002 01:33 Go to next message
jasn
Messages: 39
Registered: October 2002
Member
hOW CAMN I CALCULATE DAYS FROM THE START OF MONTH TO THE CURRENT DATE(SYSDATE)
PL HELP!
Re: DATE CONVERSION [message #22824 is a reply to message #22823] Thu, 31 October 2002 05:45 Go to previous messageGo to next message
gp
Messages: 46
Registered: September 2002
Member
hey can u put your question more clearly cos if u r looking for no of days isnt it that the date is enough cos if its 39 th today then naturally there were 29 days since start of month !!!
is it that u want to calculate from some old date or month say 1stdec 99 to today ????
Re: DATE CONVERSION [message #22826 is a reply to message #22823] Thu, 31 October 2002 06:36 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
you can get that in many ways
SQL> ed
Wrote file afiedt.buf

  1  select     sysdate,                             -- today
  2   last_daY(add_months(sysdate,-1)),              -- last day of the previous month
  3   sysdate-last_day(add_months(sysdate,-1)) days  -- (today -last day of previous month)= days in
  4                                             --month until today
  5* from dual
SQL> /

SYSDATE     LAST_DAY(AD       DAYS
----------- ----------- ----------
29-oct-2002 30-sep-2002         29

after changing sysdate

SQL> /

SYSDATE     LAST_DAY(AD       DAYS
----------- ----------- ----------
31-oct-2002 30-sep-2002         31

SQL> 

Re: DATE CONVERSION [message #22830 is a reply to message #22823] Thu, 31 October 2002 09:38 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
As gp mentions, I think the easiest way is just:

sql>select to_char(sysdate, 'dd') dm from dual;

DM
--
31


No subtraction required.
Re: DATE CONVERSION [message #22838 is a reply to message #22823] Thu, 31 October 2002 22:13 Go to previous messageGo to next message
jasn
Messages: 39
Registered: October 2002
Member
You rightly understood. Muy problem is to calculate next salary if an employee gets two or three advance salaries. Then he should be paid after due date. i want to calculate that due date.
thanx
Re: DATE CONVERSION [message #22843 is a reply to message #22838] Fri, 01 November 2002 01:48 Go to previous message
gp
Messages: 46
Registered: September 2002
Member
select sysdate,
last_daY(add_months('01-Jun-2002',-1)) +1,
sysdate-(last_daY(add_months('01-Jun-2002',-1))+1) days from dual

this should help as you need the salry from the 1st of each month you can replace hard coded date from the user in put.... i guess my solution is similar to the one proposed by someo one else also...
Previous Topic: How do i compare values from 2 columns in 1 table?
Next Topic: Attention Todd Barry or Andrew
Goto Forum:
  


Current Time: Mon Apr 29 02:16:50 CDT 2024