Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I Have a question. What must I write in the M Statement or SQL Statment to get WHERE explicit Date to NOW Date?
Quelle = Odbc.Query("dsn=mmStatistik", "SELECT * FROM mmstatistik#(IF)WHERE belegdatum >= {d '01/01/2018} AND <= ")
Solved! Go to Solution.
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN {d '01/01/2018'} AND Date()
was rellay simple...and a lucky type...
that works and gives me the actual date
Thanks for alle the help and sorry for the circumstances.
I would use normal SQL code
= "SELECT * FROM mmstatistik WHERE belegdatum >= {d '01/01/2018'} AND belegdatum <= convert(date, getdate())"
I got a parsing error with WHERE clause? What that did I typed wrong?
Or is that Convert Statement not useful for the Source Code?
I miss a quote in the first select {d, '...'}
Now I get a semicolin Expecting error...what a mess did I do :)? Where should the semicolon placed?
SELECT * FROM mmstatistik WHERE belegdatum {d '01/01/2018'} AND belegdatum <= Convert(date,getdate())
EDIT: I saw it the >= was missing 🙂
Still not working but I did a Test like this
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN {d '01/01/2018'} AND {d '01/31/2018'}
and that worked...but this doesn't
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN {d '01/01/2018'} AND Convert(Date,GetDate())
I am just guessing because I place {d ' 09/21/2018'} aswell...what output should Convert(Date,GetDate()) give me? I saw something like this 21.09.2018 in further tests. Can i change the Format in the SQL Statement? I guess it's a local date option or something like that :).
EDIT: But i the data colum it's place like 21.09.2018 aswell. And the right Culture Option is selected.
What data type has the column belegdatum?
If it's the format shouldn't matter. SQL will handle it as date and the format is just a layer.
Can you try this directly on your database.
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN convert(date, getdate()-10) AND convert(date, getdate())
that's the error i get when i use that code
I made a typo this is the correct code:
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN convert(date, getdate()-10) AND convert(date, getdate())
No still the same error...isn't there a way to change the format of the converting?
Sure:
FORMAT ( getdate(), 'd', 'de-de' )
More information: https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-2017
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN convert(date, format(getdate()-10, 'd', 'de-de')) AND convert(date, format(getdate(), 'd', 'de-de'))
still that error 😞
Dont use the convert function. The format made a string value of the date so that wont work.
SELECT
format(getdate()-10, 'd', 'de-de')
, format(getdate(), 'd', 'de-de')
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN format(getdate()-10, 'd', 'de-de') AND format(getdate(), 'd', 'de-de')
still...
guess that GetDate() is not implementet or something 😞
SELECT * FROM mmstatistik WHERE belegdatum BETWEEN {d '01/01/2018'} AND Date()
was rellay simple...and a lucky type...
that works and gives me the actual date
Thanks for alle the help and sorry for the circumstances.
What is your source database? Not mssql right? that was my assumption
Hey @Anonymous,
You can use something like :
Table.SelectRows(#"Name of Previous Step", each [#"Column Name to Filter"] = DateTime.LocalNow())
*Technically it returns a Date/Time value, where TODAY() returns a Date value. The literal closest to TODAY() is Date.From(DateTime.LocalNow()) which you should use rather than DateTime.LocalNow() alone if the column you're filtering is already a plain date type rather than date/time.*
And if i want to place it in the SQL Query?
SELECT * FROM mmstatistik WHERE belegdatum >= {d '01/01/2018'} AND <= DateTime.Date(DateTime.LocalNow())
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |