Which query will gives the exact one day difference:

SELECT COUNT(*) AS tot FROM Test WHERE DATETIME BETWEEN TO_DATE('01/01/2012 12:00:00 AM', 'DD/MM/YYYY hh:mi:ss am') AND TO_DATE('01/02/2012 11:59:59 PM', 'DD/MM/YYYY hh:mi:ss am')
SELECT COUNT(*) AS tot FROM Test WHERE DATETIME BETWEEN TO_DATE('01/01/2012 00:00:00 AM', 'DD/MM/YYYY hh:mi:ss am') AND TO_DATE('01/01/2012 11:59:59 PM', 'DD/MM/YYYY hh:mi:ss am')

hI,
First lets assume that you did not mean to have the 1-feb-2012 in the last date of the first select.
SELECT COUNT(*) AS tot FROM Test WHERE DATETIME BETWEEN TO_DATE('01/01/2012 12:00:00 AM', 'DD/MM/YYYY hh:mi:ss am') AND
TO_DATE('01/02/2012 11:59:59 PM', 'DD/MM/YYYY hh:mi:ss am')
--           XXBut you want 1-jan-2012.
Then I would not use between for this but trunc for beter readability like:
TAB AS
select to_date('2012/01/01 00:00:00', 'YYYY/MM/DD HH24:MI:SS') DATETIME FROM DUAL union all
select to_date('2012/01/01 12:17:22', 'YYYY/MM/DD HH24:MI:SS') DATETIME FROM DUAL union all
select to_date('2012/01/01 23:59:59', 'YYYY/MM/DD HH24:MI:SS') DATETIME FROM DUAL union all
select to_date('2012/01/02 00:00:00', 'YYYY/MM/DD HH24:MI:SS') DATETIME FROM DUAL union all
select to_date('2012/01/02 12:17:21', 'YYYY/MM/DD HH24:MI:SS') DATETIME FROM DUAL
SELECT
  TO_CHAR(DATETIME,'YYYY/MM/DD HH24:MI:SS') DATETIME
FROM
  TAB
WHERE
  TRUNC(DATETIME) = to_date('2012/01/01', 'YYYY/MM/DD')
;You may look into an function based index on trunc(datetime) for preformance
Regards,
Peter

Similar Messages

  • Which table will give the completion timestamp of the last success run?

    Which table will give the completion date timestamp of the last successful execution of an OWB Mapping or Process_flow.?
    I was thinking of using
    select max(RTA_LOAD_DATE|| RTA_LOAD_TIME) from OWBSYS.OWB$WB_RT_AUDIT
    where
    trim(RTA_LOB_NAME) like '%EMP_LOAD1%'
    and
    rta_status = '1'
    But the RTA_LOAD_DATE AND RTA_LOAD_TIME is null
    and RTA_STATUS column is having the value 1 irrespective of whether the JOB has completed or abended
    Please advise??

    Check with these tables :
    <b>coss
    cosl
    cosp</b>
    aufk
    qmat

  • How to query which Tcodes specified user used with one day?

    Hi guys:
      How to query which Tcodes specified user used with one day?

    Hi
    You can use transaction code ST03N.
    1. Go to tx code - ST03N
    2. Under "Workload" you can select your "Instance or Total" so that it expands and shows you Days, Week, Month.
    3. If you want to look at the transactions executed for a particular day, lets say, then double click on any day.
    4. At the bottom left you get "Analysis Views"
    5. Select & expand "User and Settlement Statistics"
    6. Double click on "User Profile"
    7. On the right side of the window you get a list of all the users
    8. Double click on a particular user you want to view the details of.
    9. The new screen will display the "Transactions/Reports Utilized by User XXX"
    If you wanna track which users executed a particular transacation then follow this:
    10. In "Analysis Views" expand "Transaction Profile"
    11. Double click on "Standard"
    You can view the list of Transactions and Reports.
    12. Double click on the Tx Code or Report you wanna check and it will show the Use of it.
    This will help you.
    Regards
    Sumit Jain
    [reward with points if the answer is useful]

  • TS2776 I used my Ipod while at the gym one day and now it's acting wacky.  I have tunes that will not download due to an "unexpected error (-50).  Anyone know what this is and how to fix it?

    I used my Ipod while at the gym one day and now it's acting wacky.  I have tunes that will not download due to an "unexpected error (-50).  Anyone know what this is and how to fix it?

    looks like the gtk theme is not the problem. didnt really think it was, but the documentation was worth posting. the guys over at ubuntu look as though they have dealt with this in great detail, and have produced a few solutions, which may or may not work. i have decided to post these for anyone else who may have these problems.
    Solution 1 - new user creation:
    https://bugs.launchpad.net/ubuntu/+bug/104521
    Solution 2 - config file delete:
    http://ge.ubuntuforums.com/showthread.php?t=724439
    post number 6 here features the config file delete solution, as well as a link to another post which may be useful.
    judging by a google search on this problem and the number of responses that came up, the bonobo/daemon error is quite a common curse for the users of gnome, although much more common in distros such as ubuntu or fedora.
    i hope that this proves useful and if anyone has anything to add, please feel free. the more documentation the better.
    EDIT:
    another solution would be to remove gnome and reinstall it from scratch. (some please tell me if i am doing this correctly. thanks )
    1. clean your catch:
    pacman -Scc
    2. remove gnome, gnome extras, and whatever other gnome files you might have installed
    pacman -Rscn gnome gnome-extra etc...
    3. reinstall gnome and gnome extras
    pacman -Sy gnome gnome-extra
    4. reconfigure your desktop the way you want.
    Last edited by czechman86 (2008-05-28 23:42:43)

  • Which table will give me the serial numbers per each delivery?

    Which table will give me the serial numbers per each delivery?

    Hi,
    Table:
    SER01 -> provide links between delivery and serial number object.
    You can select by LIEF_NR = 'delivery number'.
    OBJK -> content of serial numbers
    You can select by OBKNR = 'SER01-OBKNR'.
    Further more:
    You can check in SE11 with name "SER0*". Then you can see a list of tables which contains link between serial number to other document.
    SER01 -> Delivery
    SER02 -> Maint.Contract (SD Order)
    SER03 -> Goods Movements
    SER04 -> Inspection Lot
    SER05 -> PP Order
    SER06 -> Handling Unit-Content
    SER07 -> Physical Inventory
    SER08 -> Purchase Order Item Serial Numbers
    Regards,
    Harry

  • In Which table Will maintain the All Workflows Triggering Event Details?

    Hi,
    Can Any one tell me
    In Which table Will maintain the All Workflows Triggering Event Details?

    Hi Mohit,
    The Tr Codes KE29N/KE28L will give me the Logs of Past TDD runs. However, i would like to see the all the variants in a go. Due to a Organizational change, there is a new characteristics introduced. Now we need to change the sequence of the TDD runs. Since there are lot of TDD Variants that are in use. we need to get all of them into an excel and then decide the necessary changes.
    Thanks & Regards
    Surya

  • Which query will work fast

    Hi,
    Can anybody please suggest which query will work fast
    distinct role_cd is 1,2,3,4 and null in product table
    select * from product
    where nvl(role_cd,'4') not in '4'
    select * from product
    where role_cd in('1','2','3')
    I have 13 millions record in this table and there is no index on role_cd

    I tried this (11gR2) and get below, but still not sure if it is safe to say that the second one is better:
    create table product (role_cd char(2), id number);
    begin
    dbms_stats.set_table_stats( user, 'PRODUCT', numrows => 13000000 );
    end;
    explain plan for 
    select * from product where nvl(role_cd,'4') not in '4';
    Plan hash value: 427209646
    | Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |         |   650K|    10M|   319  (91)| 00:00:04 |
    |*  1 |  TABLE ACCESS FULL| PRODUCT |   650K|    10M|   319  (91)| 00:00:04 |
    Predicate Information (identified by operation id):
       1 - filter(NVL("ROLE_CD",'4')<>'4')
    explain plan for 
    select * from product where role_cd in('1','2','3');
    Plan hash value: 427209646
    | Id  | Operation         | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |         |   130K|  2158K|   287  (90)| 00:00:04 |
    |*  1 |  TABLE ACCESS FULL| PRODUCT |   130K|  2158K|   287  (90)| 00:00:04 |
    Predicate Information (identified by operation id):
       1 - filter("ROLE_CD"='1' OR "ROLE_CD"='2' OR "ROLE_CD"='3')

  • Why my calendar display different there is one day difference from different  when I see main screen and open the calendar

    See my Why my calendar display different there is one day difference from different  when I see main screen and open the calendar

    I too am having the same issue only I am in Regina, Canada.  iCloud appears to think Regina, Canada is in the Central time zone which it is, but it does not use Daylight Savings time.  My PC is Windows 7 and I am using Outlook 2010.  I have iCloud on iPhone 5 and iPad 2.   Terribly frustrating!

  • Which server will get the load?

    Hi all
    I have 2 servers, on 'server1', I have an flv file, on
    'server2', I have an swf file.
    The swf file on server2 loads the flv file on server1. My
    question is, which server will get the burden of the load of the
    flv file? Additionally, how can I test this to confirm this (bare
    in mind, I'm not a server guy).
    Any help is always appreciated.
    Thanks
    Chris

    You can basically publish it to one Origin Server and that server will republish the incoming stream to other 3 origin servers. This feature is called Multi-point publish. Basically you use application.onPublish and onUnpublish handlers in conjunction with Server-side NetStream Class to achieve this.
    Simple example:
    var nc;
    var ns;
    application.onAppStart = function(){
          nc = new NetConnection();
         nc.onStatus = function(info){
              // you can trace connection status here
         nc.connect("rtmp://Origin_Server_2/myApp");
    application.onPublish = function(myClient,myStream){
        ns = new NetStream(nc);
        ns.attach(myStream);
        ns.publish(myStream.name,"live");
    application.onUnpublish = function(myClient,myStream){
          ns.publish(false);

  • Where i will give the date and time of the session background process

    Hi.
    I created a program on XD01 by using Session Method.
    It is executed properly and process in forground also fine.
    What my problem is i want execute process of session in Back ground on that time i want give the Date and Time. I do not know where i will provide date and Time.
    I want Process the BDC Session after 2 days. How it is possbile. Where i will give the date and Time?
    With in these 2 days i want know the status of the Session Process. How i will check the status?
    Any body will explain these things with full flow of sequence.
    I do not want use the BDC Session by using RSBDCSUB. In that program there is no options for giving the Date and Time.
    Thank You.
    B. Krishna.

    Hi,
    While creating session through BDC_OPEN_GROUP function, populate HOLDDATE field to set lock on the created session till that date, say 31.12.2008 and you would like to execute your session on 1.1.2009 at 2:00 AM.
    Once session is created, create a batch job for program RSBDCSUB and schedule it on 1.1.2009 at 2:00 AM (server time).
    I am confident that it solves your problem.
    Regards,
    Prasanth

  • TFS 2012 - WebAccess - how to define which Query will run by default when navigating to WORK- WorkItems page

    When we nagivate in IE in TFS Web Access, to the WORK -> Work Items page, TFS runs the AssignedToMe query and focuses on it as sort of default query that runs in such event. We have some teams under the team project, but AssignedToMe is not sensitive
    to Team, only to Team Project, hence when navigating to the page of the specific team, this query shows the same per all teams :(.
    In order to bypass this, we'd like to set a specific team query to be the default one to run when navigating to the team's page, instead of AssignedToMe, and thus have the result specific to each team scope.
    Alternatively if it is possible to somehow filter AssignedToMe query according to Team Scope it would be great. Alas there's no @Team field yet, and we don't wish to create multiple AssignedToMe queries and name each specific to each team, nor do we wish
    to put team queries in MyFavorites while naming them specifically per team..
    Kindly advise, thank you

    Hi Moital,  
    Thanks for your post.
    As far as I know there’s no default way to the default query(AssignedToMe) in Work Items page, we usually add uses in different teams. If the user want to view the work items in one specific team, he can create a my query to filter work items according team
    field value.
    Yes, as you said there’s no @Team value in Team field to filter current team’s work items in work item query, so if you want create the shared query according team values, you need create this shared query for each team.
    For the Team field, please refer to the information in this document:
    https://msdn.microsoft.com/en-us/library/dn144940(v=vs.110).aspx.
    For this scenario, you can submit it to User Voice site at: http://visualstudio.uservoice.com/forums/121579-visual-studio. Microsoft engineers will evaluate them
    seriously.  
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Photos won't import images from my Canon camera.  When connected, program sees the images, tells me it will import the new ones, then freezes once import starts, not allowing any other operation to happen.  MacbookPro 15" 2012, OSX Yosemite 10.10.3.

    Photos won't import images from my Canon camera.  When connected, program sees the images, tells me it will import the new ones, then freezes once import starts, not allowing any other operation to happen.  MacbookPro 15" 2012, OSX Yosemite 10.10.3.  Any suggestions?

    Solution discovered.  Faulty connector cable.  Tried a different one and it worked.

  • Which table will give vendor master details per company code per purchase o

    Which table will give vendor master details per company code per purchase organisation that is all details available in XK03?

    hi
    Check T code MKVZ
    Or table LFA1
    Vishal...

  • Who will give the request number for a package?

    hi
    who will give the request number for a package , while releasing a package in se10 or se09

    Hi Shivika
    Please educate me, what is a package number? What does it relate? How and from where to get the number?
    The package number i refer is the service package number. The package number is being asked for when i refer the tables ESLH and ESLL.
    Regards
    Vijay

  • Which app will read the square information codes?

    which app will read the square information codes?

    Search the playstore for QR code reader - here are a few:
    QR Code Reader - Android Apps on Google Play
    QR Code Scan & Barcode Scanner - Android Apps on Google Play
    QR Code Scan & Barcode Scanner - Android Apps on Google Play

Maybe you are looking for

  • "Do not import duplicates" is greyed out

    When importing pictures in Aperture I cannot select the "Do not import duplicates" (nor the "Automatically split projects"). Any reason I can't use these settings? Thanks...

  • Nokia having problem in designing the back cover f...

    did anybody noticed the difference of 5800xm between taking picture with the back cover and without the back cover? i can only tell that, the picture taken with back cover is juz too **bleep**, while the picture taken without back cover is clear, viv

  • Can't get Dual Channel mode to work

    Hello, I have a pair of 512MB DDR400 ram sticks (listed in my sig). The Memory Slots are arranged like this:             1 2   3   [cpu]    |  |    | I put each stick in slot 1 and 2 and no workie, still Single Channel Mode. I put a stick in slot#2 a

  • Aperture 3 shuts off without warning

    I have recently upgraded to Aperture 3 and while my Aperture library did not have many photos to transfer to the new system I just imported all of my past work so that I could begin to organize and edit all of my photos. Since importing all of my pic

  • Latest debug version crashing in Firefox a lot

    Hello, The last debug version gave me no problems in Firefox.  But the current debug version crashes if I start tracing through code randomly. I'm not sure if this is Flash debug or Firefox update. Anyone else experiencing this? ,Jim