IS THERE A FUNCTION TO RETURN THE NUMBER OF MONTHS OR DAYS?

I know that you can do a months between function between 2 dates divided by 12 and get years but is there a function that can return the number of months between 2 dates or the number of days between 2 dates in a select statement for a report? These 2 dates are entered in an Oracle forms.
I have 2 dates.
BEG_SVC_DT 30-JUL-1995 DATE FORMAT
END_SVC_DT 981007 VARCHAR2 FORMAT Positions 5 and 6 are the days.
I must subtract BEG_SVC_DT from END_SVC_DT.
In PLSQL I add 31 to 07 and get 38. I subtract 30 from 38 and get 8.
or I have 2 dates
BEG_SVC_DT 10-JAN-2003 DATE FORMAT
END_SVC_DT 050924 VARCHAR2 FORMAT Positions 5 and 6 are the days.
I must subtract BEG_SVC_DT from END_SVC_DT.
In PLSQL I subtract 10 from 24 and get 14.
In both scenarios the end_dt field must be VARCHAR2 because the user has to enter the word 'PRESENT' . Is there a function in SQL that would compute the
number of days between 2 dates?
Is there a function to get the number of months between 2 dates?
I have 2 dates.
BEG_SVC_DT 12-JUL-2004 DATE FORMAT
END_SVC_DT 050807 VARCHAR2 FORMAT Positions 3 and 4 are months.
I must subtract BEG_SVC_DT from END_SVC_DT
JUL is the 7th month.
In PLSQL, I subtract 07 from 08 and get 01
Or I have 2 dates
BEG_SVC_DT 13-NOV-2004 DATE FORMAT
END_SVC_DT 050429 VARCHAR2 FORMAT Positions 3 and 4 are months.
I must subtract BEG_SVC_DT from END_SVC_DT.
NOV is the eleventh month. 04 is less than 11.
In PLSQL I have to add 12 to 04 and subtract 11 from 16 to get 05.
In both scenarios, the end_dt field must be VARCHAR2 because the user has to enter the word 'PRESENT'. In SQL, is there a function to compute the number of months between 2 dates?
I am doing my calculations this way because this is the way that the user has been doing them when they created the report manually.
The database that I am using is Oracle 9.2.0.6
Report Writer Report Builder 6.0.8.22.0
Forms 6.0.8.22.1

In your example:
BEG_SVC_DT 30-JUL-1995 DATE FORMAT
END_SVC_DT 981007 VARCHAR2 FORMAT Positions 5 and 6 are the days.
I must subtract BEG_SVC_DT from END_SVC_DT.
In PLSQL I add 31 to 07 and get 38. I subtract 30 from 38 and get 8.
Where is the "31" depending on, on year and month of BEG_SVC_DT or END_SVC_DT?
What would be the answer for the following example
BEG_SVC_DT 25-FEB-1995 DATE FORMAT
END_SVC_DT 980407 VARCHAR2 FORMAT
Do I add 28 (=number of days in FEB-1995),
or 30 (=number of days in APR-1998),
or 31 (= max number of days in any month?)

Similar Messages

  • Is there any function that returns the latest DDL statement

    can anyone tell me if there is any FUNCTION that returns latest DDL statement performed in a schema.
    OR
    if there is any TABLE that will be populated with latest
    DDL statement in schema.
    THANK YOU.

    The table all_objects (and/or dba_objects) contains a column called last_ddl_time. Thus, a query like
    scott@jcave > SELECT max(last_ddl_time)
      2  FROM all_objects
      3 WHERE owner = 'SCOTT';
    MAX(LAST_DDL_TI
    28-NOV-03will tell you the last time any object owned by SCOTT had DDL issued against it.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Function to return the Entry Value based on Assignment, Element and Date

    Hi Guys,
    Is there a function that returns the Entry Value for the Assignment Element, based on the Assignment Number, Element Name, Entry Segment and the End of Period date?
    Example:
    ==============
    Input Parameters:
    Employee: Iana
    Assignment Num: 123
    Element: D480
    Element Entry: Fund Name
    Output Parameter:
    Element Entry Value: MLC Super Fund
    Thanks,
    Iana

    For element entry values you can use:
    select petf.element_name, nvl(peevf.screen_entry_value,0) screen_entry_value
    from
    pay_element_entries_f peef, pay_element_types_f petf,
    pay_element_entry_values_f peevf, pay_input_values_f pivf,
    per_all_assignments_f paaf
    where petf.element_type_id = peef.element_type_id
    and :p_date_earned between pivf.effective_start_date and pivf.effective_end_date
    and :p_date_earned between petf.effective_start_date and petf.effective_end_date
    and peevf.input_value_id = pivf.input_value_id
    and paaf.assignment_id = peef.assignment_id
    and petf.business_group_id = :p_business_group_id
    and peevf.element_entry_id = peef.element_entry_id
    and :p_date_earned between peef.effective_start_date and peef.effective_end_date
    and :p_date_earned between peevf.effective_start_date and peevf.effective_end_date
    and :p_date_earned between paaf.effective_start_date and paaf.effective_end_date
    and pivf.name = :p_input_value_name
    and petf.element_name = :p_element_name
    and peef.entry_type = 'E'
    and peevf.effective_start_date = peef.effective_start_date
    and peevf.effective_end_date = peef.effective_end_date
    --and peef.assignment_id = :p_assignment_id
    and paaf.assignment_number = :p_assignment_number;
    For payroll results you can use:
    select sum(prrv.result_value)
    from pay_run_results prr, pay_run_result_values prrv,
    pay_assignment_actions paa, pay_payroll_actions ppa,
    pay_element_types_f petf, pay_input_values_f pivf,
    per_all_assignments_f paaf, per_all_people_f papf
    where
    petf.element_type_id = pivf.element_type_id
    and :p_pay_date between petf.effective_start_date and petf.effective_end_date
    and :p_pay_date between pivf.effective_start_date and pivf.effective_end_date
    and paa.assignment_action_id = prr.assignment_action_id
    and petf.element_type_id = prr.element_type_id
    and ppa.payroll_action_id = paa.payroll_action_id
    and prrv.input_value_id = pivf.input_value_id
    and prr.run_result_id = prrv.run_result_id
    and petf.element_name = :p_element_name
    and pivf.name = :p_input_value_name
    and ppa.date_earned = :p_pay_date
    and papf.person_id = paaf.person_id
    and nvl(prr.start_date,ppa.effective_date) between paaf.effective_start_date and paaf.effective_end_date
    and nvl(prr.start_date,ppa.effective_date) between papf.effective_start_date and papf.effective_end_date
    and paaf.assignment_id = paa.assignment_id
    and papf.employee_number = :p_employee_number;

  • Where can I find a method to return the number of constants in an enum?

    I'd like to get the number of constants in an enum, but can not find any documentation on the topic.
    The only method I find reference to is the values() method.
    Are there other methods?
    Is there a method to return the number of items in the values array?
    Thanks,
    Norm

    Encephalopathic wrote:
    A_Sailor wrote:
    I had a mental block there.In my field, we call this a "cerebral spasm".From what I know of your field, that's a strange place to keep your cerebrum ;-)

  • Problem with a simple function that return a number

    Hi,
    I'm writing a function that return a number. I receive always an error (invalid number) but I don't understand why.
    The function is this:
    >
    FUNCTION COUNT_OBJECT(workflow_name_p IN NUMBER, object_type_p IN VARCHAR2) RETURN NUMBER
    IS
    object_inserted NUMBER;
    BEGIN
    object_inserted := 0;
    IF workflow_name_p = 'AIMDailyIngestorWorkflow'
    THEN
    object_inserted := 1;
    else
    object_inserted := 100;
    END IF;
    RETURN object_inserted;
    END COUNT_OBJECT;
    I have left only an if and an assignment because I do not find the error.
    When I execute the function I receive always this error:
    ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    There are not operation, only assignment I cannot understand.
    Could someone help me?
    Thanks bye bye.

    I changed in this way:
    FUNCTION COUNT_OBJECT(workflow_name_p IN VARCHAR2, object_type_p IN VARCHAR2) RETURN NUMBER
    IS
    object_present NUMBER;
    object_inserted NUMBER;
    table_name_p VARCHAR2(4000);
    query_stmt VARCHAR2(4000);
    BEGIN
    IF workflow_name_p = 'AIMDailyIngestorWorkflow'
    THEN
    SELECT SUM(B.STOREDOBJS) INTO object_present
    FROM DPCTJOBTYPESTATS B
    WHERE B.WORKFLOW_NAME = workflow_name_p AND B.OBJTYPE=object_type_p;
    SELECT 'AIM.'||B.TABLE_NAME INTO table_name_p
    FROM DPCTSWOBJTYPE B
    WHERE B.OBJTYPE=object_type_p AND SOFTWARE='AIM';
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || table_name_p || ';' INTO object_inserted;
    object_inserted := object_inserted - object_present;
    END IF;
    RETURN object_inserted;
    END COUNT_OBJECT;and now the error is:
    ORA-00911: invalid character
    ORA-06512: at "INFRA.WORKFLOW_STATISTICS", line 504
    00911. 00000 - "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    but the line 504 is the blank line higlighted with the ***.
    Why this error? The code seems correct.
    Thanks, bye bye.

  • View or function to return the full path hierarchy of an organization

    Hi,
    The customer is asking to provide a report showing for each assignment of each employees the corresponding organization where it is assigned and the full path of the organization hierarchy.
    The organization hierarchy is at most 6 level deep, so they want to produce the report with the columns:
    root_organization | org_level1 | org_level2 | org_level3 | org_level4 | org_level5 | org_level6 | person_name | assignment_date
    if the person is assigned in an organization lower than the 6th level, the remainin columns should be empty.
    I see that the view HRFG_ORGANIZATION_HIERARCHIES returns only one step in the organizations hierarchy: Parent_organization_name, Child_organization_name.
    Is there any view or function as well which returns the full path of an organization in the hierarchy? At least a function which returns the full path parents of the organization delimited by commas.
    Thank you

    Hi,
    Yes, I wrote a custom code but is running a bit slowly for around 1000 organizations and more than 15 version of hierarcy (so 15000 rows of this view). I wanted to know if there is any optimized code provided by Oracle.
    Thank you.

  • Is there a way to find the number of downloads of music from itunes store?

    Hi,
    Is there any way to find the number of downloads of each music file available on itunes store. If not exact no of downloads but atleast a relative term to find the rank of the music track From any API
    Thanks
    Sandeep

    A: Is there a way to read the number of active sequence executions from the Engine?

    Scott,
    > One way of handling the issue of init once a set of instruments is to
    > create a new sequence file that has a sequence to init and a sequence
    > to close the instruments. Assuming that you always terminate a
    > sequence and do not abort them, you could add a ProcessSetup and
    > ProcessCleanup callback sequences to the client sequence file that
    > using these instruments. These callbacks are automatically called by
    > the process model in both the Single Pass and Test UUTs execution
    > entry points. The callback sequences could call the init and close
    > sequences for the hardware. In the hardware sequence file you could
    > reference count the number of execution that init and close by setting
    > the file globals in the sequence file to be shared across executions
    > and then add a numeric value that keeps track of references for the
    > instruments. The init sequence adds to the count, and the close
    > sequence subtracts from the count. The init sequence inits the HW if
    > the count is 0->1 and the close sequence closes the HW if the count is
    > 1->0.
    >
    > This is one of many ways in TestStand that this could be done, not to
    > mention that this could also be done in a similar way in a LabVIEW VI
    > or DLL directly.
    That sounds like it will work. I'll try adding a client count
    increment/decrement in the DLL initialize and terminate functions. This
    should essentially perform the same tasks as the callback scheme you mention
    above, no?
    The reason I didn't think the 'client counting' scheme would work initially
    was I mistakenly thought that the termination function would not get called
    under Terminate conditions. Since Terminate conditions happen a LOT during
    our initial debug of new UUT types, I didn't think that would be acceptable.
    I forgot that lacing the terminate funciton in a cleanup step group, I can
    force it to be called in Terminate conditions.
    > If you abort an execution then the reference counting idea above would
    > fail to decrement properly. That might b... [Show more]

    Read other 5 answers

  • Search function only returns the first entryinstead of 2600

    Hi all,
    I am using JDNI to search in a iPlanet LDAP. This is the code:
    String filter = "(objectclass=TDC-Empleado)";
    NamingEnumeration resultados;
    SearchControls limitacionesBusqueda=new SearchControls();
    limitacionesBusqueda.setSearchScope(SearchControls.SUBTREE_SCOPE);
    results = ctx.search("o=TDC",filter,limitacionesBusqueda);
    I know with another tool that this filter works but the search function only returns the first entry!!!
    Somebody can help me ?
    TIA
    Manuel

    humm.
    Sets ctx.setCountLimit(long), or else checks the "size limit" of your iplanet server (size limit: number of entries returned to the client application).
    A.V.

  • Function that returns the date/time ?

    We would like to make a validation in the Activity status based on the activity End Time.
    Pls... is there a function that returns something that I could compare with: "8/6/2009 01:00 PM" ?
    I know of Today but I understand that today() returns just the day (no time).
    Txs.
    Antonio

    Hi Antonio,
    You can try using the function -: Timestamp()
    To quote the CRM On Demand help files...
    "+The Timestamp function in Expression Builder returns the server date and time converted to the current user's time zone setting. For example, if the current user's time zone setting is set to Eastern Daylight Time (EDT) -0400 UTC, the Timestamp function converts the server time to EDT. The TimeStamp function performs UTC (universal time code) conversion. NOTE: Arithmetic operations (for example, add or subtract) are not supported with the Timestamp() function.+"
    Hope this helps.
    Regards,
    Cameron

  • Is there any function to get the name of the days?

    Hi,
    I'm using oracle 10.2.0.1.0
    Is there any function to get the days of the week?
    like i need to get sunday,monday,tuesday.....saturday.
    I know i can use union and select the name from dual one by one.
    But just want to know whether there is any other way.
    I need to show the 7 days in a poplist in my form, thats the requirement
    Thanks

    David_Aldridge wrote:
    BluShadow wrote:
    Note: you may want to include "fm" in the format mask, otherwise the name of the day is padded with spaces:
    SQL> ed
    Wrote file afiedt.buf
    1  select replace(to_char(dt,'Day'),' ','*') as fmt1
    2        ,length(to_char(dt,'Day')) as length_fmt1
    3        ,replace(to_char(dt,'fmDay'),' ','*') as fmt2
    4        ,length(to_char(dt,'fmDay')) as length_fmt2
    5  from (select TRUNC(SYSDATE ,'DAY')+Level-1 dt
    6        from   dual
    7        connect by Level<8
    8*      )
    SQL> /
    FMT1      LENGTH_FMT1 FMT2      LENGTH_FMT2
    Monday***           9 Monday              6
    Tuesday**           9 Tuesday             7
    Wednesday           9 Wednesday           9
    Thursday*           9 Thursday            8
    Friday***           9 Friday              6
    Saturday*           9 Saturday            8
    Sunday***           9 Sunday              6
    7 rows selected.
    SQL>
    I think you should use a pl/sql function for this.
    Nah ... just joking.
    I'd be tempted to just use a union all statement to return the seven literals. People will look at it and know exactly what it does.Yeah, agreed, I was just demonstrating that the format mask of a to_char(..., 'Day') pads with spaces, which seems to have been missed in the above answers. ;)

  • Which system field returns the number of records returned after a select?

    Which system field returns the number of records returned after a select?
    a) sy-index
    b) sy-recno
    c) sy-lncnt
    d) sy-dbcnt
    e) sy-tabix

    Hi,
       SY-DBCNT
    Regards,
    Prashant

  • Is there a recommended limit on the number of custom sections and the cells per table so that there are no performance issues with the UI?

    Is there a recommended limit on the number of custom sections and the cells per table so that there are no performance issues with the UI?

    Thanks Kelly,
    The answers would be the following:
    1200 cells per custom section (NEW COUNT), and up to 30 custom sections per spec.
    Assuming all will be populated, and this would apply to all final material specs in the system which could be ~25% of all material specs.
    The cells will be numeric, free text, drop downs, and some calculated numeric.
    Are we reaching the limits for UI performance?
    Thanks

  • Is there a way to control the number of concurrent SMTP connections on Database Mail?

    Las week Rackspace started controlling the number of concurrent SMTP connections and we are now getting the following message when we send as little as 15 messages at a time using Database Mail:
    Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: 4.7.0 smtp13.relay.dfw1a.emailsrvr.com Error: too many connections from IP xxx.xxx.xxx.xxx)
    We are using SQL Server 2005 and Windows 2003 and we have been doing this since 2006 with no problems
    Is there a way to control the number of concurrent SMTP connections used by Database Mail or the Database Mail external executable DatabaseMail90.exe?

    Hi rkohler,
    Usually, we can use the Database Mail Configuration Wizard or the Database Mail stored procedures to determine the server name and port number for the Simple Mail Transfer Protocol (SMTP) server . In the SMTP server points, we can set or increase the number
    of concurrent connections.
    There is similar issue about database email on SQL Server 2005, you can refer to the following post.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/6bb7b600-f025-451b-898b-2caa29c10d4d/only-some-email-gets-sent-successfully-from-spsenddbmail-database-mail-on-sql-server-2005
    Thanks,
    Sofiya Li
    If you have any feedback on our support, please click here.
    Sofiya Li
    TechNet Community Support

  • Is there a function to get the IP of this remote system

    Hello EveryBody
    Currently I have an application that runs on our network. When someone logs on to the network it checks there system and gets the pc name. I would like to also get the IP address of that system. As well I may later like to ping that computer.
    1) Is there a function to get the IP of this remote system?
    2) IS the a function to ping a remote system and receive back the response?
    Thanks a lot.
    R

    Hello EveryBody
    Currently I have an application that runs on our
    network. When someone logs on to the network it
    checks there system and gets the pc name. I would
    like to also get the IP address of that system. As
    well I may later like to ping that computer.
    1) Is there a function to get the IP of this remote system?
    2) IS the a function to ping a remote system and
    receive back the response?Is this lan only?
    Because if wan or internet then the remote computer would have to have an address that is reachable from your computer. For the internet this would mean it would have to be public. And for a wan the IP would have to be unique across the wan.

  • Loop through a csv file and return the number of rows in it?

    What would be simplest way to loop through a csv file and
    return the number of rows in it?
    <cffile action="read" file="#filename#" output="#csvstr#"
    >
    <LOOP THROUGH AND COUNT ROWS>

    ListLen(). Use chr(13) as your delimiter

Maybe you are looking for

  • Do i need phantom power for a condenser mic to use with garageband?

    i have learned condenser mics need phantom power. if i would hook up a MXL 900 series condenser to my MacBook via an XLR to 1/8" cable, would it work? does garageband have some sort of amplification plug-in? or would i need some sort of mixer or oteh

  • Recording screen and sound?

    Does quicktime pro record video and audio of the screen?

  • N85 internet call

    Hi I have a Nokia N85 which i am trying to get internet calls working on. I have downloaded and installed the VoIP settings V3 app. I can make outgoing internet calls but the phone won't receive internet calls. Any suggestions as to why this might be

  • How to enable the prebooking tab in ESS

    Hi, In our environment, the prebooking tab is disabled in ESS. Please advise how to enable this tab. Where to do this configuration (e.g. in ESS or R/3) Regards, Tony

  • Lumia 800 - Music store user ID

    Hi - Can I create a new user ID in Nokia Music in the existing Lumia 800 phone? If I reset the Lumia 800 and create a new user ID can I browse Nokia Music on the existing phone? I was told that we cant access the new user ID on the same phone as the