Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi,
I have defined a function and named E_Date to generate the short date formate (i.e 01-Nov-24) to be embedded in SQL in power query. However, I'm not sure why it return null!
= "01-"&Text.Start(Date.MonthName(DateTime.LocalNow()),3)&"-"&Text.End(Date.ToText(DateTime.Date(DateTime.LocalNow())),2)The output is exactly what I need (01-Nov-24), however it return nothing to embedded query.
.... DATE <= '"&E_Date&"'...
Hi @samahiji ,
Pls has your problem been solved? If so, accept the reply as a solution. This will make it easier for the future people to find the answer quickly.
When embedding E_Date in your SQL query, ensure that the syntax is correct. For example:
let
SQLQuery = "SELECT * FROM Table WHERE DATE <= '" & E_Date & "'"
in
SQLQuery
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Oh--in that case just escape the single quote like this:
'' (that is two apostrophes).
So
"SELECT...FROM...
WHERE DATE <= ''"&E_Date&"''AND..."
Remember, that's an apostrophe escaping an apostrophe.
--Nate
Looks like you just need to remove those single quotes. So
"SELECT...FROM...
WHERE DATE <= "&E_Date&" AND..."
--Nate
The single quotes are required for the sql date to run. It returns error when removed.
I added the single quotes inside the function itself but it didn't work though.
However, creating parameter will solve the issue, but I need to make it dynamic.
= "'"&"01-"&Text.Start(Date.MonthName(DateTime.LocalNow()),3)&"-"&Text.End(Date.ToText(DateTime.Date(DateTime.LocalNow())),2)&"'"
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 7 | |
| 5 | |
| 5 |