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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors