View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Patrick Dave Patrick is offline
external usenet poster
 
Posts: 249
Default Passing parameter to a select query

If I were passing to SQL Server then I would pass it in as a string
something like;

SELECT SUM(fld_hours) AS SumHours
FROM tbl_techtime
WHERE (fld_time_started = CONVERT(DATETIME, ' & mydate & ', 102))

SELECT SUM(fld_hours) AS SumHours
FROM tbl_techtime
WHERE (fld_time_started = CONVERT(DATETIME, ' & mystartdate & ', 102)
AND fld_time_started <= CONVERT(DATETIME, ' & myenddate & ', 102))

SELECT SUM(fld_hours) AS SumHours
FROM tbl_techtime
WHERE (fld_time_started BETWEEN CONVERT(DATETIME, ' & mystartdate & ',
102) AND CONVERT(DATETIME, ' & myenddate & ', 102))

No idea really with oracle.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Seamus Conlon" wrote:
|I have a worksheet that I need to update on a daily basis
| with data from an external Oracle database. I am using
| the following query which gets yesterday's data (the Oracle
| data is always for the previous day).
|
| SELECT Sum(recno) FROM mailboxes
| WHERE (trunc(logdate)=trunc(sysdate-1))
|
| This sums the values in the rec_no column for all rows
| that were logged yesterday. The thing is that on a Monday,
| I need to get the data for both Saturday and Sunday so
| would need to be able to pass the date as a parameter
| rather than having to manually change the query.
|
| How does one do this?
|
| Many thanks,
| Seamus
|
|