Showing posts with label criteria. Show all posts
Showing posts with label criteria. Show all posts

Monday, March 26, 2012

Microsoft Query?

i am using the following criteria in the [DateTime] field;

>=#3/9/2007# And <=#3/12/2007 11:59:59 PM#

i am using microsft query and excel to create pivot tables, i created an odbc file to connect to my local server


[DateTime] [TagName] [Value]
2007-03-09 00:00:00.000 PS002_Pump1.Daily_Runtime 1.1833188533782959
2007-03-09 00:00:00.000 PS002_Pump2.Daily_Runtime 1.4499822854995728
2007-03-09 04:59:59.947 PS002_Pump1.Daily_Runtime 0.16666463017463684
2007-03-09 04:59:59.947 PS002_Pump2.Daily_Runtime 0.13333170115947723
2007-03-09 09:59:59.893 PS002_Pump1.Daily_Runtime 0.51666033267974854
2007-03-09 09:59:59.893 PS002_Pump2.Daily_Runtime 0.48332741856575012
2007-03-09 14:59:59.843 PS002_Pump1.Daily_Runtime 0.86665606498718262
2007-03-09 14:59:59.843 PS002_Pump2.Daily_Runtime 0.86665606498718262
2007-03-09 19:59:59.790 PS002_Pump1.Daily_Runtime 1.083320140838623
2007-03-09 19:59:59.790 PS002_Pump2.Daily_Runtime 1.1333194971084595
2007-03-10 05:59:59.683 PS002_Pump1.Daily_Runtime 0.18333110213279724
2007-03-10 05:59:59.683 PS002_Pump2.Daily_Runtime 0.18333110213279724
2007-03-10 10:59:59.630 PS002_Pump1.Daily_Runtime 0.49999389052391052
2007-03-10 10:59:59.630 PS002_Pump2.Daily_Runtime 0.56665974855422974
2007-03-10 15:59:59.577 PS002_Pump1.Daily_Runtime 0.83332318067550659
2007-03-10 15:59:59.577 PS002_Pump2.Daily_Runtime 0.93332195281982422
2007-03-10 20:59:59.527 PS002_Pump1.Daily_Runtime 1.1166530847549438
2007-03-10 20:59:59.527 PS002_Pump2.Daily_Runtime 1.2833176851272583
2007-03-11 07:59:59.420 PS002_Pump1.Daily_Runtime 0.14999817311763763
2007-03-11 07:59:59.420 PS002_Pump2.Daily_Runtime 0.24999694526195526
2007-03-11 12:59:59.367 PS002_Pump1.Daily_Runtime 0.56665974855422974
2007-03-11 12:59:59.367 PS002_Pump2.Daily_Runtime 0.69999146461486816
2007-03-11 17:59:59.317 PS002_Pump1.Daily_Runtime 0.81665670871734619
2007-03-11 17:59:59.317 PS002_Pump2.Daily_Runtime 0.98332130908966064
2007-03-11 22:59:59.263 PS002_Pump1.Daily_Runtime 1.1833188533782959
2007-03-11 22:59:59.263 PS002_Pump2.Daily_Runtime 1.3666499853134155
2007-03-12 03:59:59.210 PS002_Pump1.Daily_Runtime 0.11666524410247803
2007-03-12 03:59:59.210 PS002_Pump2.Daily_Runtime 0.08333231508731842
2007-03-12 08:59:59.157 PS002_Pump1.Daily_Runtime 0.23333048820495605
2007-03-12 08:59:59.157 PS002_Pump2.Daily_Runtime 0.28332987427711487
2007-03-12 13:59:59.107 PS002_Pump1.Daily_Runtime 0.66665852069854736
2007-03-12 13:59:59.107 PS002_Pump2.Daily_Runtime 0.76665729284286499
2007-03-12 18:59:59.053 PS002_Pump1.Daily_Runtime 0.89998900890350342
2007-03-12 18:59:59.053 PS002_Pump2.Daily_Runtime 1.0166542530059814
2007-03-12 23:59:59.000 PS002_Pump1.Daily_Runtime 1.1999853849411011
2007-03-12 23:59:59.000 PS002_Pump2.Daily_Runtime 1.3833163976669312


what i would like to do is not hard code the date for the data i need, is there a way to code the dates so that microsoft query
would pull those date from sql...ie;

[DateTime]

>= CONVERT(VARCHAR(20), GETDATE()-5, 100) 12:00:00 AM and <= CONVERT(VARCHAR(20), GETDATE(), 100) 11:59:59 PM

any ideas?

Can't you just use:

WHERE [DateTime] BETWEEN GETDATE() - 5 AND GETDATE()

Chris

|||no , because you only get the data for the current date and time. I need to code this so that it will pick up all data between 12:00:00 am and 11:5:59 pm for each date.|||

Just to clarify - if you ran the query now (15-Mar-2007 20:23:32.000) then you would expect to return data from 10-Mar-2007 00:00:00.000 to 15-Mar-2007 23:59:59.999 inclusive.

Is this correct?

If so, then this could help:

WHERE [DateTime] >= CAST(CONVERT(VARCHAR(8), GETDATE() - 5, 112) AS DATETIME)
AND [DateTime] < CAST(CONVERT(VARCHAR(8), GETDATE() + 1, 112) AS DATETIME)

Chris

|||Thank You Chris, that worked like a charm...Have a great weekend.

Monday, February 20, 2012

Message for Blank Reports

Sometimes there are cases where no records match the selection criteria. When that occurs, I want to display a message such as "No Data This Report". Preferably this would be where you would expect to see the first detail line.
I would appreciate any ideas on this. Thanks.If you call the report fron Front end, check whether there are records for the query used in CR. If there are no records then call the Blank Report which display "No Records Found". So you have to have two records; one actual report and other one is dummy|||Tried it and it works great. Thanks a bunch!