Please help with VBA code for searching between dates

D4WNO

New member
Joined
May 29, 2013
Messages
4
Reaction score
0
Points
0
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 [COLOR=#ff0000]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') )[/COLOR] [COLOR=#0000ff]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') )[/COLOR] [COLOR=#008000]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') )[/COLOR]
 

D4WNO

New member
Joined
May 29, 2013
Messages
4
Reaction score
0
Points
0
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 :)
 

royUK

New member
Joined
Mar 22, 2011
Messages
155
Reaction score
0
Points
0
Location
Derbyshire, UK
Website
www.excel-it.com
Excel Version(s)
most versions
I suggest that you post your code again, use Code Tags but not the Color Tags. Then it will be readable & copyable.
 

D4WNO

New member
Joined
May 29, 2013
Messages
4
Reaction score
0
Points
0
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') )
 
Top