Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set variable date range in query?
Hi,
At the moment I'm looking into getting data from a database into Excel. One problem I have is entering the date range in which the data from the database must adhere to. I do not want to have to open the query each time to change the start and finish dates. When I have two ranges in a sheet, called 'start' (imagine it in cell B1) and 'finish' (placed in cell B2), how should I read 'start' and 'finish' into the query? Should the WHERE clause have something like: SELECT ... DATEADD (T.Created, INTERVAL HOUR (TIMEDIFF(TIME(NOW(), UTC_TIME())) HOUR CREATED, DATEADD (T.Resolved, INTERVAL HOUR (TIMEDIFF(TIME(NOW(), UTC_TIME())) HOUR RESOLVED WHERE "start" <= CREATED AND CREATED <= "finish" Note: T.Created and T.Resolved are (date) fields in the database I query. Who knows what I need to fill in in the WHERE clause? Abel |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set variable date range in query?
Dim dtStart
Dim dtEnd dtStart = cDate(ActiveSheet.Range("B1")) dtEnd = cDate(ActiveSheet.Range("B2")) and use this variables in query. If this post helps click Yes -------------- Jacob Skaria "Abel MacAdam" wrote: Hi, At the moment I'm looking into getting data from a database into Excel. One problem I have is entering the date range in which the data from the database must adhere to. I do not want to have to open the query each time to change the start and finish dates. When I have two ranges in a sheet, called 'start' (imagine it in cell B1) and 'finish' (placed in cell B2), how should I read 'start' and 'finish' into the query? Should the WHERE clause have something like: SELECT ... DATEADD (T.Created, INTERVAL HOUR (TIMEDIFF(TIME(NOW(), UTC_TIME())) HOUR CREATED, DATEADD (T.Resolved, INTERVAL HOUR (TIMEDIFF(TIME(NOW(), UTC_TIME())) HOUR RESOLVED WHERE "start" <= CREATED AND CREATED <= "finish" Note: T.Created and T.Resolved are (date) fields in the database I query. Who knows what I need to fill in in the WHERE clause? Abel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trying to make Date Range variable in VBA SQL Query | Excel Programming | |||
remote query & date range? | Excel Programming | |||
How do I enter a date range ie -7 from current date in MS QUERY | Excel Discussion (Misc queries) | |||
HOW DO I CHANGE QUERY DATA TO A DATE RANGE? | Excel Worksheet Functions | |||
Changing fixed date with a variable in a ODBC Query | Excel Programming |