+ Reply to Thread
Results 1 to 1 of 1

SQL Expression for Date Range in PowerBI Query

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    SQL Expression for Date Range in PowerBI Query

    Hi

    I have the expression below which seeks to get certain fields from a table where the date is between the two dates in the expression. However, there is something wrong with the statement - what is it?

    Thank YOu

    Allister

    The code is

    let
    Source = GetConsolidatedSQLData("Select accountcode, branchcode, departmentcode, transactiondate, transactionamount, periodno, yearno, periodid from GLTRAN where transactiondate between '1/7/2018 00:00:00' and '2/7/2018 00:00:00'"),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"AccountCode", type text}, {"BranchCode", type text}, {"DepartmentCode", type text}, {"PeriodNo", type text}, {"YearNo", type text}, {"PeriodID", type text}, {"CompanyCode", type text}, {"TransactionAmount", Currency.Type}, {"TransactionDate", type date}})

    in
    #"Changed Type"

    the error I get is


    An error occurred in the ?GetSQLData? query. DataSource.Error: Web.Contents failed to get contents from 'http://Company('NLD')/ExecuteSql('Select%20accountcode,%20branchcode,%20departmentcode,%20transactiondate,%20transactionamount,%20periodno,%20yearno,%20periodid%20from%20GLTRAN%20where%20transactiondate%20between%20'1/7/2018%2000:00:00'%20and%20'2/7/2018%2000:00:00'')' (400): Bad Request
    Details:
    DataSourceKind=Web
    DataSourcePath=http://Company('NLD')/ExecuteSql('Select%20accountcode,%20branchcode,%20departmentcode,%20transactiondate,%20transactionamount,%20periodno,%20yearno,%20periodid%20from%20GLTRAN%20where%20transactiondate%20between%20'1/7/2018%2000:00:00'%20and%20'2/7/2018%2000:00:00'')
    Url=http://Company('NLD')/ExecuteSql('Select%20accountcode,%20branchcode,%20departmentcode,%20transactiondate,%20transactionamount,%20periodno,%20yearno,%20periodid%20from%20GLTRAN%20where%20transactiondate%20between%20'1/7/2018%2000:00:00'%20and%20'2/7/2018%2000:00:00'')
    Last edited by AllisterB; 11-25-2022 at 11:41 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Powerbi add number of workdays to current date to return weeknumber
    By TtNl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2022, 08:07 AM
  2. Expression Query
    By ajh19742000 in forum Access Tables & Databases
    Replies: 0
    Last Post: 06-14-2022, 06:56 AM
  3. How to fix an expression error in power query?
    By Dexter2 in forum Excel General
    Replies: 4
    Last Post: 04-01-2022, 08:02 PM
  4. Discrepancy in casting date type: PowerQuery vs PowerBI
    By immigrated4urjob in forum Excel General
    Replies: 0
    Last Post: 01-31-2022, 02:32 PM
  5. Syntax error in date in query expression "#".
    By baijixu in forum Access Tables & Databases
    Replies: 3
    Last Post: 06-12-2014, 11:05 PM
  6. Syntax Error in Query Expression
    By acmagyar in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2013, 03:11 PM
  7. [SOLVED] Missing Operator in Query Expression
    By dollylectric in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-19-2012, 02:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1