• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Power Pivot Help - SQL code working sort of?

lwilt

Member
When I'm using PP and trying to bring down data from the SQL server I'm using the following code:

SELECT BILLING.BILLING_SOLD_ACCNO, BILLING.BILLING_ORIG_ORDNO, BILLING.BILLING_ORIG_ORD_DATE, BILLING.BILLING_ORIG_OPR, BILLING_ORDER_ITEMS.BILLING_ITEM
FROM BILLING INNER JOIN BILLING_ORDER_ITEMS ON BILLING.u2_id = BILLING_ORDER_ITEMS.u2_id
WHERE (((BILLING.BILLING_ORIG_ORD_DATE)>=6/1/2016));

My data comes in for the fields I want but it brings in the entire table instead of based on the date range that I'm trying to do. What am I doing wrong for setting the criteria I want that date range to be so it just brings in information starting at that date?

My other question is I was also trying to do one other criteria on the data coming in but it keeps getting errors....in that the 3rd line looked like:
WHERE (((BILLING.BILLING_ORIG_ORD_DATE)>=6/1/2016) AND ((BILLING.BILLING_ORIG_OPR) Not Like "WebSite"));

It had the same two lines as above before the third line. For the field Billing_orig_opr I'm trying to not bring in any data that has WebSite in that field but it doesn't seem to like that and I've tried to put it in a few different ways.

Can't figure what I'm doing wrong....Please help.


thank you.
 
This is more of SQL question. But something like this.
If the column is in appropriate format...
Code:
WHERE BILLING.BILLING_ORIG_ORD_DATE>='6/1/2016';
If not...
If SQL server 2008 or up try...
Code:
WHERE Cast(BILLING.BILLING_ORIG_ORD_DATE as Date)>='6/1/2016';

If older version try...
Code:
WHERE CONVERT(char(10), BILLING.BILLING_ORIG_ORD_DATE, 120)>='6/1/2016';
 
Back
Top