Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default How do you automatically update criteria in MS Query

Hi

I am pulling data out of an ODBC database into Excel using MS Query. I would like to write a criteria where the query includes only the previous 12 months of data (TODAY()-365). Is this possible?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default How do you automatically update criteria in MS Query

Yes, very possible and handy: First, in Excel, put your
formula =(TODAY()-365) into a cell. Then, in MSQuery, put
the appropriate date field into the criteria grid and on
the criteria line enter a parameter, e.g. [StartDate].
Then "Return Data to Excel" and when the Query Properties
box comes up choose "Parameters..." You will get a dialog
box that allows you to specify how MSQuery will interpret
the parameter StartDate. Tell it to get the value from a
cell and specify the cell containing your formula.

-----Original Message-----
Hi

I am pulling data out of an ODBC database into Excel

using MS Query. I would like to write a criteria where
the query includes only the previous 12 months of data
(TODAY()-365). Is this possible?

TIA
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default How do you automatically update criteria in MS Query

"K Dales" wrote ...

I am pulling data out of an ODBC database into Excel
using MS Query. I would like to write a criteria where
the query includes only the previous 12 months of data
(TODAY()-365). Is this possible?


Yes, very possible and handy: First, in Excel, put your
formula =(TODAY()-365) into a cell.


Your database server should more accurately provide this info, rather
than obtaining it locally e.g.

Jet ('MS Access'):

SELECT Now

SQL Server:

SELECT GetDate()

You could use this in a query e.g. for Jet:

SELECT
RefID, DateEffective, Earnings
FROM
EarningsHistory
WHERE
DateEffective BETWEEN
DateSerial(Year(Now)-1, Month(Now), Day(Now))
AND Now
;

Jamie.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query criteria based on a changing criteria list bwilk77 Excel Discussion (Misc queries) 2 May 27th 09 04:03 PM
Update one worksheet tab to automatically update all other tabs? shoechic1 Excel Worksheet Functions 1 May 24th 09 03:55 PM
Can a macro be automatically run after an update from MS query? AndyT Excel Discussion (Misc queries) 4 November 7th 08 03:27 PM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Update Query Roger Bell New Users to Excel 1 October 11th 07 11:34 AM


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"