Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Norbertus
Helper V
Helper V

variable with date of today

Hi,

 

I used an SQL statement to get the data from a stored procedure. In this statement i use a date field and works fine when i use a variable as startdate.

 

The variable (startdate) is defined as:

#date(2018, 3, 6) meta [IsParameterQuery=true, Type="Date", IsParameterQueryRequired=true]

 

Now i want that the default date (2018, 3 ,6) changed to the present date. How can i do this?

when i use "DateTime.Date(DateTime.LocalNow())" for the date, the syntax doen't work

 

With kind regards,

 

 

 

2 REPLIES 2
Norbertus
Helper V
Helper V

The stored procedure is: exec storedprocedure '2018-03-07', '2018-03-07'

the 2 dates must be default the date of today (Startdate and Enddate)

for these dates I made a variabele and implemented it in de sourcecode:

 

Source = Sql.Database("xx", "xxx", [Query="exec storedprocedure '"&Date.ToText(Startdate"yyyyMMdd")&"', '"&Date.ToText(Endate,"yyyyMMdd")])

 

But now i have to change everyday the variable to the date of today. How can i change this default?

 

Startdate = #date(2018, 3, 7) meta [IsParameterQuery=true, Type="Date", IsParameterQueryRequired=true]

dramus
Continued Contributor
Continued Contributor

The syntax for "DateTime.Date(DateTime.LocalNow())" looks good, it returns todays date.

 

Maybe it's in the wrong format for your stored procedure?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.