#1 2021-12-07 07:45:18

age
Member
Registered: 2021-11-04

formatting of dates for default value in parameters

I need to dynamically find the last Sunday from any weekday a date parameter of a report.
Appendix C details format components, but show no examples how to use them. No syntax or synopsis of a "format" command is given either.

I am thinking of
{format(u,today()) = 1 ? today.addDays(-1) : format(u,today()) =2 ? today.addDays(-2) : ... and so on to trawl through all weekday numbers

An example of how to format today() to get the day of the week as a number would be nice. And an example how to use the ternary in the default field of a parameter would be much appreciated.


As an aside,  if appendix C could be furnished with some examples, that might make the documentation useful to more users.

Last edited by age (2021-12-07 07:47:45)

Offline

#2 2021-12-07 08:07:06

eduardo
Administrator
Registered: 2016-11-01
Website

Re: formatting of dates for default value in parameters

Hi age,

are you talking about appendix c or appendix b? In b you have firstDay, lastDay, addDays, etc: https://reportserver.net/en/guides/user … -language/ Pls take a look here.

Regards,
Eduardo

Offline

#3 2021-12-07 08:09:04

eduardo
Administrator
Registered: 2016-11-01
Website

Re: formatting of dates for default value in parameters

Hi age,

if you are talking about appendix b, this is linked in the bottom of the page: https://docs.oracle.com/javase/7/docs/a … ormat.html
so this is standard java formatting. You should find tons of examples on the internet as it is standard for java.

Regards,
Eduardo

Offline

#4 2021-12-07 13:07:44

age
Member
Registered: 2021-11-04

Re: formatting of dates for default value in parameters

${math: ... } doesn't work in a parameter of datatype date
Looks like RS doesn't parse for the output datatype of a function, e.g. ${today.addSeconds(1).format("u")} in a parameter field of datatype integer doesn't work either, despite format supposedly producing a whole number from 1 through 7 (see appendix C)


6.9.1. Using the today object
has 2 formatting examples, one of which is

${today.firstDay().addSeconds(-1).format("dd/MM/yyyy")}

--
I'll pass another parameter to the stored procedure to deal with the date range I need.

Offline

Board footer

Powered by FluxBB