ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Microsoft Query? (https://www.excelbanter.com/excel-programming/385263-microsoft-query.html)

Mark J

Microsoft Query?
 
I am using Microsoft Query to query against an SQL database and place the
data into a pivot table but cannot figure out how to get the preceding 4 days
worth of data. I currently am trying to get this to work using the following;

=#3/13/2007# And <=#3/13/2007 11:59:59 PM#...this works, but i would like this so the report will run without hard coding dates.. i am trying to use this but with no luck.


=getdate() And <=dateadd(dd,-1,getdate())


any ideas?


[email protected][_2_]

Microsoft Query?
 
Format your dates as YYYYMMDD in your SQL (assuming you can edit it -
I recall that you can). That will make it so that when you create a
pivot table where the data covers more than one calendar year that the
columns will end up in the right place. Also, Excel can do strange
things with date formatting. I for get the exact example, but
something like "1-10" always assumes the current year. YYYYMMDD will
resolve that issue too.



All times are GMT +1. The time now is 08:41 AM.

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