Forum Discussion
SQL Query with Actual Date
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 <= ")- Anonymous7 years ago
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.
22 Replies
- DaFloDoResolver I
hi Anonymous,
DateTime.LocalNow() gives you the current DateTime.
DateTime.Date(DateTime.LocalNow()) results in only the current date.
best regards,
florian
- AnonymousNot applicable
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.*
- AnonymousNot applicable
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())- DaFloDoResolver I
Hi Anonymous,
try
= "SELECT * FROM mmstatistik WHERE belegdatum >= {d '01/01/2018'} AND belegdatum <= '" & Date.ToText(DateTime.Date(DateTime.LocalNow())) &"'"Quelle = Odbc.Query ( "dsn=mmStatistik", "SELECT * FROM mmstatistik WHERE belegdatum >= {d '01/01/2018'} AND belegdatum <= '" & Date.ToText(DateTime.Date(DateTime.LocalNow())) &"'" )regards
florian
- richardverburgHelper I
I would use normal SQL code
= "SELECT * FROM mmstatistik WHERE belegdatum >= {d '01/01/2018'} AND belegdatum <= convert(date, getdate())"- DaFloDoResolver I
- AnonymousNot applicable
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?