Not able to use date with time in sql query

Hi,
select a.contract_number,b.start_date,b.end_date,b.price_negotiated,b.attribute_category,b.attribute1,a.sts_code,a.contract_number_modifier,b.cle_id,b.creation_date
from OKC_K_HEADERS_ALL_B a,OKC_K_LINES_B b
where a.id = b.dnz_chr_id
and b.cle_id is not null
and a.contract_number_modifier is not null
and a.sts_code in ('ACTIVE','SIGNED','60 DAY HOLD','HOLD')
and b.creation_date between to_date('21-10-2013 9:19:48','DD-MM-YYYY HH24:MI:SS')  and  sysdate;
If I execute this query in toad it is giving me proper results.This query populates the results between the two date with time.
But I am facing issue when I am using this query in the procedure. The procedure is as below.
If I use the same query in the procedure I am getting wrong output.
CREATE OR REPLACE procedure xx_prog_upd_annualized_amt(errbuf out varchar2, retcode out varchar2)
as
cursor c1 (l_date in varchar2)is
select a.contract_number,b.start_date,b.end_date,b.price_negotiated,b.attribute_category,b.attribute1,a.sts_code,a.contract_number_modifier,b.cle_id
from OKC_K_HEADERS_ALL_B a,OKC_K_LINES_B b
where a.id = b.dnz_chr_id
and b.cle_id is not null
and a.contract_number_modifier is not null
and a.sts_code in ('ACTIVE','SIGNED','60 DAY HOLD','HOLD')
and b.creation_date between  to_date(l_date,'DD-MM-YYYY HH24:MI:SS')  and  sysdate;
v_date varchar2(100);
v_total_days number;
v_annualized_amount number;
begin
begin
select max(fcr.actual_start_date) into v_date
from fnd_concurrent_programs_vl fcp
,fnd_concurrent_requests fcr
where fcp.concurrent_program_id = fcr.concurrent_program_id
and fcp.user_concurrent_program_name like 'Renewed Annualized Amount Updation';
exception
when others then
fnd_file.put_line(fnd_file.log,'Invalid date');
end;
fnd_file.put_line(fnd_file.output,v_date);
fnd_file.put_line(fnd_file.output,sysdate);
fnd_file.put_line(fnd_file.output,'***************Start of Program***************');
fnd_file.put_line(fnd_file.output,'***************Hi***************');
For i in c1(v_date) loop
SELECT
         1
       + 30 * TRUNC (MONTHS_BETWEEN ( TO_DATE (i.end_date, 'DD-MON-YYYY'),  TO_DATE (i.start_date, 'DD-MON-YYYY')))
       + LEAST (EXTRACT (DAY FROM TO_DATE (i.end_date, 'DD-MON-YYYY')), 30)
       - LEAST (EXTRACT (DAY FROM TO_DATE (i.start_date, 'DD-MON-YYYY')), 30)
       + CASE
            WHEN EXTRACT (DAY FROM TO_DATE (i.end_date, 'DD-MON-YYYY')) < EXTRACT (DAY FROM TO_DATE (i.start_date, 'DD-MON-YYYY')) THEN 30
            ELSE 0
         END
          daysbetween into v_total_days
  FROM dual;
  fnd_file.put_line(fnd_file.output,i.contract_number);
  fnd_file.put_line(fnd_file.output,v_total_days);
  If v_total_days < 360 then
  v_annualized_amount := (360*i.price_negotiated)/v_total_days;
  update OKC_K_LINES_B
  set attribute_category = 'Annualized Amount',attribute1 = v_annualized_amount
  where cle_id = i.cle_id;
   fnd_file.put_line(fnd_file.output,v_annualized_amount);
    fnd_file.put_line(fnd_file.output,i.cle_id);
    elsif v_total_days >= 360 then
  update OKC_K_LINES_B
  set attribute_category = 'Annualized Amount',attribute1 = i.price_negotiated
  where cle_id = i.cle_id;
  end if;
end loop;
commit;
fnd_file.put_line(fnd_file.output,'***************End of Program***************');
null;
end;

SureshM wrote:
Hi Purvesh,
Apologize for not giving the sufficient information.
max(fcr.actual_start_date) = here I am getting date with time (for eg :9/4/2012 6:47:49 PM)
Datatype for this column is date.
This actual start date I am storing in varchar2 variable and then converting this value to date with time.
My requirement is to pick the rows between the two timestamps which I am unable to do in the procedure.
Regards
Suresh
YOu are losing the Time information while fetching the data into a VARCHAR2 variable. change the datatype of v_date to DATE and get rid of the TO_DATE logic in cursor and simply use v_date variable.
Message was edited by: PurveshK misread.

Similar Messages

  • TS4022 I am not able to use iclould with Internetexplorer.

    I am not able to use iclould with Internetexplorer.  I was able to until November.  I have been way and on my return I can not even log in usin IE.  I can using Chrome.  I am an IE user so would like help please?

    This may not work for everyone, but I solved this problem by clicking on the file name in sharepoint, not the document icon to the left of the name. This then brought up the various options, including checking out, editing, version history etc. It seems obvious but I have only just realised this!

  • Not able to use password with characters for RFC User.

    hi All,
    I have installed SAP SCM 5.0 with MaxDB 7.6and liveCache 7.6.
    I created RFC user and RFC destination to administer liveCache globally as per SAP notes 305634 and 452745. I changed the initial passwords and tested Remote login for RFC User.
    But when I try to start liveCache with startrfc following the link below
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/95/379f3cad1e3251e10000000a114084/frameset.htm
    I got the following error
    RFC Call/Exception: SYSTEM_FAILURE
    Group       Error group 104
    Key         RFC_ERROR_SYSTEM_FAILURE
    Message     Name or password is incorrect (repeat logon)
    Then I logged into the CI with RFC user and try to start the liveCache with RSLVCSTART T-Code SE38..I got the following error.
    Error DBMCLI_COMMAND_EXECUTE_ERROR when starting liveCache LCS on server saplcslc
    Message no. LVC007
    I tried by changing the password for RFC user to numeric [0-9] and special characters [$,:] which worked fine.
    Does anyone faced this issue earlier? I searched notes, sdn and finally google ... but no luck to resolve the issue.
    Your help is much appreciated.
    Thanks,
    Venkat

    Yes I used LCA as liveCache connection. I resolved the issue with RSLVCSTART. Thanks for your suggestion to run connection test. I used wrong password for control user in the LCA connection. Now LCA connection shows everything is fine.
    But I am still not able to use alphanumeric password RFC user to start the liveCache from command line. I get the following when run startrfc command...
    bash-3.00$ /usr/sap/CAT/rfcsdk/bin/startrfc -3 -d LCSCLNT001 -h sapcatci -s 51 -c 001 -u LCSRFC -p Mach1cspsap\$ -l EN -F START_LIVECACHE_LVC -E IV_CON_NAME=LCA
    RFC Call/Exception: SYSTEM_FAILURE
    Group       Error group 104
    Key         RFC_ERROR_SYSTEM_FAILURE
    Message     Name or password is incorrect (repeat logon)
    bash-3.00$ echo $?
    1
    But I can start the liveCache from command line with numeric password successfully.
    bash-3.00$ /usr/sap/CAT/rfcsdk/bin/startrfc -3 -d LCSCLNT001 -h sapcatci -s 51 -c 001 -u LCSRFC -p 19811983\$ -l EN -F STOP_LIVECACHE_LVC -E IV_CON_NAME=LCA
    bash-3.00$ echo $?
    0
    Note the difference between the passwords used. Do i need to change any settings to accept alphanumeric passwords for RFC user.
    Note that I am able to start liveCache server in both cases(alphanumeric password and numeric password) by logging into SAP GUI and RSLVCSTART program. The problem is only when i try to start the liveCache from the commandline.
    Any help will be much appreciated.
    Thanks,
    Venkat

  • Not able to set date and time

    I have a problem with automatic date and time will not initiate. I have wireless connection verified; my DHCP is properly configured, the latest i-Tunes software update, homesharing ID matched with computer and security firewall verified configured properly for allowing all incoming connections. Second Apple TV 2 bought in past two days where it will not update wirelessly. Is this a port problem, NTP, or related to software update that went wrong?
    Contacted router vendor to troubleshoot their device. Verified with my computer, the wireless router works. Has anyone seen this problem before?
       Thanks!

    Welcome to the Apple Community.
    If you have previously been able to use your Apple TV without this problem, you might try restarting the Apple TV by removing ALL the cables for a 30 seconds. if this doesn't help try a restore.

  • I am not able to use Firefox with Sharepoint - I can only open a file in read-only mode and cannot checkout the document and edit.

    I would like to use Firefox with Sharepoint.
    However, I am only able to open a file in "read only" mode whch means I cannot edit the document and save it. I am also not able to "check-out" a document in Sharepoint and edit it at the same time.

    This may not work for everyone, but I solved this problem by clicking on the file name in sharepoint, not the document icon to the left of the name. This then brought up the various options, including checking out, editing, version history etc. It seems obvious but I have only just realised this!

  • Network not able to set date and time

    Live outside of US and have my new Apple TV set to my Air Express WiFi network but I have not found a way to set the date and time. I have set my region time zone but stll no luck. I cannot move forward with the installation until I resove this problem. So far my Apple TV is only good for Air Play of my Spotify music and YouTube. Without date and time can't even set iTunes. Help!

    Welcome to the Apple Community.
    Assuming this is not the first time you have used your Apple TV
    You might try restarting the Apple TV by removing ALL the cables for 30 seconds.
    Also try restarting the router. (Also try removing it’s power cord for at least 30 seconds)
    If the problem persists, try a restore, you may want to try the previous procedures several times before doing this.
    If restoring from the Apple TV doesn't help, try restoring from iTunes using a USB cable.
    If this is a new Apple TV, in addition to trying the above, it may also be that your network router is not allowing access to the timeserver, check that your router allows access over port 123.

  • Not able to adjust date and time - format does not permit

    Hello,
    I just scanned one old photo as a JPG and then imported it to Aperture 2, I renamed the file 1976-07-01_01.jpg based on the date the pic was taken. Then I tried to adjust the date and time in Aperture but got this error window:
    "Unable to adjust master file
    Aperture was not able to adjust the date and time of the master file "pic.jpg" because it has a format that does not permit date modification."
    What next?

    I am having a similar problem. The time is off by 12 hours exactly (ahead). When I touch date and time, screen goes black for less than a second and then reverts to main screen with all of the icons. I have first generation touch and just noticed this problem. All of the software is up to date. Any one know of a fix for this?

  • Query regarding OdiInvokeWebService, not able to use it with any webservice

    I am trying to invoke a webservice using the OdiInvokeWebservice, but not able to do that, tried with 11.1.1.6 and 11.1.1.5
    any one tried that before in the following version ?
    Please help !!
    Regards,
    Uday

    What did Orange say when you requested them to unlock the iPhone?
    You have to request an unlock - it is not automatic after a period of time.

  • Not able to use collection multiple times in a jsp using logic:iterate

    I have following question:
    I am working on a report using J2EE. I have a collection(resultset) which has 3 different types of vendors information along with other information in the collection and I want to put them into 3 different sections on my report depend on vendor type in the collection (resultset).
    Anyone know that I can able to use same collection multiple times uisng <logic:iterate> or is any other way of doing this.
    Thanks,

    Enable the logs on your router. Then try to do remote desktop. It will fail of course. After it does, view the logs, there might be ports listed in the incoming logs that you failed to forward.

  • My apple TV not able to set date and time

    Pl let me know how to signin in iTunes in apple as date and time is not working

    Assuming this is not the first time you have used your Apple TV
    You might try restarting the Apple TV by removing ALL the cables for 30 seconds.
    Also try restarting the router. (Also try removing it’s power cord for at least 30 seconds)
    If the problem persists, try a restore, you may want to try the previous procedures several times before doing this.
    If restoring from the Apple TV doesn't help, try restoring from iTunes using a USB cable.
    If this is a new Apple TV, in addition to trying the above, it may also be that your network router is not allowing access to the timeserver, check that your router allows access over port 123.

  • Not able to adjust Date and Time

    For about a month now I haven't been able to manually adjust the time and date. Everything else on my iPod works fine... but when I click to change time and date it just goes black for about one second then goes back to the main menu. I don't think anything has been added to it that is unsafe.. but to be sure I scanned all my folders that are on my iPod and then scanned my entire computer. Nothing came up in the scan.
    I do have the most up to date version of the software that is out.
    It currently says that it is Friday, February 23, 2007 at 5:33pm. It changed it's time and date on it's own... I can't correct it.
    So if anyone knows how to fix this please tell me how.

    I am having a similar problem. The time is off by 12 hours exactly (ahead). When I touch date and time, screen goes black for less than a second and then reverts to main screen with all of the icons. I have first generation touch and just noticed this problem. All of the software is up to date. Any one know of a fix for this?

  • Not able to use Bluetooth with Mitsubishi Outlander (2014)

    I have a new iPhone 6 with iOS ver: 8.1.3 and I am able to pair the phone with the car (Bluetooth) system, Bluetooth says it's connected, but I am unable to make/receive calls using Bluetooth. On the phone it shows that it is connected via Bluetooth, but it is not as the call is being carried out via the actual headset not the Bluetooth.  Every other phone works without any issues so I know this is not a car problem as I've tested several devices,  iPhone is the only device that is not  able to maintain proper Bluetooth connection. I've googled this and apparently this is widespread issue, so the question is, when will Apple issue a proper fix for this.
    I've tried resetting network settings as well as deleting bluetooth devices and doing a new pairing procedure but no luck.
    Please provide some feedback when this can be resolved, hopefully with the new software release cause I've never been so upset like I am right now after spending that much money on the phone that doesn't work properly.

    Hey there Andriy,
    Welcome to Apple Support Communities.
    It sounds like you’ve done quite a bit of troubleshooting in an attempt to resolve the issue making and receiving calls with your iPhone 6 that is connected to your car stereo with Bluetooth. If you haven’t already, try the general troubleshooting suggestions in the article linked below.
    iOS: Troubleshooting Bluetooth connections - Apple Support
    Ciao,
    -Jason

  • I am not able to see the trace files for SQL query

    Hello, I am using windows vista OS.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    SQL>
    I enabled the trace as below
    alter system set timed_statistics=TRUE
    alter system set sql_trace=TRUE
    After this, I ran sql query from scott as below.
    select count(*) from emp;
    After this, i checked in user dump directory. The trace files are generating... But this sql code is not appearing in the trace files...
    Am i missing anything... Any help is appreciated.
    Thanks

    This may happen when the trace file is not completely closed.You may try again doing like this,
    alter session set sql_trace=true;
    select * from emp;
    alter session set sql_trace=false;After this,disconnect and exit from your session as well. This should close the file completely and you should be able to see your command in it.
    HTH
    Aman....

  • Not Able To Use Acrobat With Updates

    Hello,
    When I slipstream all the quarterly updates through 9.5.5 into an original installation of Acrobat Pro 9 Extended which is version 9.0 the installer loads as version 9.5.5 and successfully installs Acrobat as a version 9.5.5 but when I open Acrobat and accept the license agreement I immediately receive a popup message that says the program is broke and cannot be used due to license discrepancies to reinstall it then when I click OK or terminate the process that generated the message Acrobat closes. If I install Acrobat as version 9.0 and manually apply the updates through 9.5.5 Acrobat works with no problems. Any assistance in helping me resolve the problem would be appreciated.
    My reason for wanting to install version 9.0 as version 9.5.5 is I thought it might take up less space on my hard drive but it doesn't it still uses about 4.6GB of space which is significantly more than any other program on my computer. When I tried customizing the installation with the customization tool by selecting do not copy the installation files to the hard drive Acrobat still created over a gigabit of installer files in the installer folder in the Windows directory and created over a gigabit of update files in its folder under programs. Acrobat is quite a pig isn't it I am saddened to see that this is what hard drive space is being used for in world of larger hard drives. I would like to see programs like Acrobat function with 500 characters of code or less. That would be intuitive wouldn't it.
    Sincerely,  

    I have never heard of slipstreaming the updates with the original install, only with updates themselves. I suspect that may be related in some sense, but just a guess.

  • Personalization  Not able to use Date type.

    Hi,
    When I am using the following code:
    <property name="location" value="United States">
    <property name="plainDescription" value="Date"/>
    <property name="personalization" value="dialog"/>
    <property name="type" value="date"/>
    </property>
    I dont get the Date an input box with the JavaScript Calendar, can someone suggest what might be wrong.
    Best Wishes,
    John

    Hi,
    This link may be useful to create date navigator using class lib and tag lib
    http://help.sap.com/saphelp_erp2005/helpdata/en/80/9d0e41a346ef6fe10000000a1550b0/frameset.htm

Maybe you are looking for