Scheduled Reports: StartDate/EndDate Parameters

Hello,

I am trying to run a daily report. I want the report to execute at 5 am every day and the values from the tags in the data source to be from 3 am that day. When I do a preview using StartDate todate('2025-09-25 00:03:00') and EndDate now() everything looks like it should in the report.

However, the report schedule is using the StartDate parameter:

todate(stringFormat('%s-%s-%s 03:00:00',getYear(now()),getMonth(now()),getDayOfMonth(now))

and EndDate:

addDays(todate(stringFormat('%s-%s-%s 03:00:00',getYear(now()),getMonth(now()),getDayOfMonth(now)),1)

Which appears to be breaking the output on the report itself. It only shows the header values and none of the tag values.

I will note that I am new to reporting in Ignition and scripting in general and had to get someone to send me something to try for the StartDate and EndDate parameters. I am hoping the seasoned vets can help me out.

Thanks

This is going the long way around to get your needed dates. I usually do something like this

addHours(midnight(now(0)),3) // 3am of current date

you can reference other parameters in expressions, so for endDate you could do this

addDays({startDate},1)
2 Likes

Ok. I will try that! We were able to get the report to work by changing the expression a little bit to this:

todate(stringFormat('%s-%s-%s 03:00:00', toint(getyear(now(0))),toint(getmonth(now(0)))+1, toint(getdayofmonth(now(0)))))

And changing the endDate to:

now(0)

That expression is an atrocity, don’t use it :wink:

3 Likes

Using string parsing after string formatting is extremely unwise. It is both slow and subject to subtle flaws, particularly in regards to timezones and midnight crossings. Don't do it.