Database Stored Procedure with Date Parameters

I have a stored procedure that accepts 2 parameters, @StartDate and @EndDate. When I pass the parameters through they are sent as long date strings instead of a simple date in the format "mm/dd/yy". This causes the proc to error out. It works fine if I execute it manually from the database with the proper date format.

Hi @joshwilliam,

Try using the toISOString() method of the date: ${CustomStartDate.toISOString()}

That did it but there seems to be something odd happening. When I first select a date it triggers the stored procedure with the correct parameters but it does not update the chart the data is tied to. If I then select the date again it triggers the proc again and updates the chart. This happens every time. I have to select the date twice for some reason. Any idea what would be causing this. I have validated with the browser dev tools that the proc is being triggered with the correct dates.



Probably the CustomStartDate property hasn't updated yet. Try using the ${event}: ${event.toISOString()}

It happens with changing it to ${event.toISOString()} as well.


We will need more info. For example how is the chart configured?

Here is the chart itself. It is populated from the Stored Procedure returned data.

The Select Bar allows you to choose the view you want. The one not working is Custom. The CustomDate parameter here is only used to toggle the view of the labels and date pickers for the Custom parameters, ie not visible on other views.

Here is the current setup for the StartDate change event to execute the proc.

Here is the End Date change event to execute the proc.

It seems that you invoke the stored procedure twice: once when you set the start date and another time when you set the end date. Is that correct? Also since you have two datepickers when does the chart actually work? After you select the first date twice or the second date twice?

You can check in your browsers developer tools what parameters is the stored procedure called with. They should be available as part of the query string. I suspect the parameters are incorrect in some of the cases - you can verify that via the browser developer tools.

Here is what it looks like when I Click custom. The start and end dates are set on page load to today's date but the proc is not executed on page load, only when the date from the picker is changed.

Here is the date change. I set the Start Date to 11-1-2019. The chart is not updated.

Here is a view showing the actual result of the stored procedure. Data is returned. Chart is not up to date.

After I set the value of the start date for a 2nd time, it executed the proc again and this time the data is shown in the chart.

I noticed something. You are assigning a different page property in the then event of the Invoke. You should set Top10Customers instead of Top10CustomersCustom. The Set action which is after the Invoke executes too early - before the stored procedure has returned a result. Remember that Invokes are asynchronous and that's why you need to use their Then event. Right now you invoke the procedure and immediately set the Top10Customers property to undefined (because Top10CustomersCustom has not been set yet).

That did it thanks.