ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table & Dates (https://www.excelbanter.com/excel-programming/382402-pivot-table-dates.html)

Mark J

Pivot Table & Dates
 
I have the following query in microsoft query,

SELECT v_AnalogHistory.DateTime, v_AnalogHistory.TagName,
v_AnalogHistory.Value, v_AnalogHistory.wwRowCount
FROM Runtime.dbo.v_AnalogHistory v_AnalogHistory
WHERE (v_AnalogHistory.TagName='PS004_Pump1.Daily_Runtim e') AND
(v_AnalogHistory.DateTime={ts '2007-01-01 00:00:00'} And
v_AnalogHistory.DateTime<={ts '2007-01-14 23:59:59'}) OR
(v_AnalogHistory.TagName='PS004_Pump2.Daily_Runtim e') OR
(v_AnalogHistory.TagName='PS004_Pump1.Daily_Starts ') OR
(v_AnalogHistory.TagName='PS004_Pump2.Daily_Starts ')

what i would like to do is just grab the last 14 days of data..ie

v_AnalogHistory.DateTime=GetDate()
And v_AnalogHistory.DateTime<=GetDate()-14

is this possiable?

Jim Thomlinson

Pivot Table & Dates
 
What is GetDate? Is that a function you have written? In any case what you
need to do is to write the SQL using the native SQL of the database you are
connecting too. You can not use anything other than the native SQL commands.
if it is just the last 14 days that should be fairly easy to do.

--
HTH...

Jim Thomlinson


"Mark J" wrote:

I have the following query in microsoft query,

SELECT v_AnalogHistory.DateTime, v_AnalogHistory.TagName,
v_AnalogHistory.Value, v_AnalogHistory.wwRowCount
FROM Runtime.dbo.v_AnalogHistory v_AnalogHistory
WHERE (v_AnalogHistory.TagName='PS004_Pump1.Daily_Runtim e') AND
(v_AnalogHistory.DateTime={ts '2007-01-01 00:00:00'} And
v_AnalogHistory.DateTime<={ts '2007-01-14 23:59:59'}) OR
(v_AnalogHistory.TagName='PS004_Pump2.Daily_Runtim e') OR
(v_AnalogHistory.TagName='PS004_Pump1.Daily_Starts ') OR
(v_AnalogHistory.TagName='PS004_Pump2.Daily_Starts ')

what i would like to do is just grab the last 14 days of data..ie

v_AnalogHistory.DateTime=GetDate()
And v_AnalogHistory.DateTime<=GetDate()-14

is this possiable?



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com