Results 1 to 6 of 6

Thread: Please help with VBA code for searching between dates

  1. #1

    Please help with VBA code for searching between dates



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi everyone, I currently have the below code but was hoping I could improve this because I currently select 3 different variants, but specify the dates separately for each. Ideally I'd like to only have one date search so I only have to change one set of dates. I've separated off each section in a different colour. I've tried bracketing them differently and having just one date atthe end but can't seem to get it quite right- is anyone able to help please?

    Code:
    select TICKET_ID_ "Ticket ID" from ARAdmin.DATABASE_NAME where TYPE = 'INFORMATION ANALYSIS APP' AND (CATEGORY = 'CERPS BI') AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND  TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') ) OR TYPE = 'MIDDLEWARE SERVICES' AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND  TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') ) OR TYPE = 'MANUFACT AND SUPPLY CHAIN' AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND  TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') )

  2. #2
    Conjurer royUK's Avatar
    Join Date
    Mar 2011
    Location
    Derbyshire, UK
    Posts
    155
    Articles
    0
    Excel Version
    most versions
    Cross posted here

    Also here
    Hope that helps

    Roy

  3. #3
    I'm really very sorry, I had missed the part about stating if you've posted on multiple forums, my mistake completely.

    I was just quite desperate for an answer but unfortunately I haven't received any replies on any of the boards anyway, I'm clicking refresh on each of them about every 5 minutes so would update/lock each thread if someone is in fact able to assist

  4. #4
    Conjurer royUK's Avatar
    Join Date
    Mar 2011
    Location
    Derbyshire, UK
    Posts
    155
    Articles
    0
    Excel Version
    most versions
    I suggest that you post your code again, use Code Tags but not the Color Tags. Then it will be readable & copyable.
    Hope that helps

    Roy

  5. #5
    Quote Originally Posted by royUK View Post
    I suggest that you post your code again, use Code Tags but not the Color Tags. Then it will be readable & copyable.
    Thank you for your advice Roy, I really appreciate that. The code is below:

    Code:
    select TICKET_ID_ "Ticket ID" from ARAdmin.DATABASE_NAME where TYPE = 'INFORMATION ANALYSIS APP' AND (CATEGORY = 'CERPS BI') AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') ) OR TYPE = 'MIDDLEWARE SERVICES' AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') ) OR TYPE = 'MANUFACT AND SUPPLY CHAIN' AND ((TO_DATE(TO_DATE('01/01/1970 00:00:00','MM/DD/YYYY HH24:MI:SS') + ((LAST_UPDATED)/(86400)), 'DD/MM/YYYY HH24:MI:SS')) BETWEEN TO_DATE('01/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') AND TO_DATE('30/05/2013 23:59:59','DD/MM/YYYY HH24:MI:SS') )

  6. #6
    Solution now found - thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •