Announcement

Migration of this forum

Dear users of this forum,

we are pleased to inform you that we will be updating the software behind this forum in the near future.

Existing posts, users and categories will remain untouched.

Important:

  • Each user will need to reset their password.
  • Please select "I forgot my password".
  • Enter the email address you used to register in this forum.
  • You will receive an email with a link to set a new password.
  • Please choose a new (secure) password and confirm the process.

We will keep you informed in the pinned thread.

Kind regards,
Your ReportServer Team


Migration des Forums

Liebe Nutzer dieses Forums,

wir freuen uns, euch mitteilen zu können, dass wir in naher Zukunft die Software hinter diesem Forum aktualisieren werden.

Existierende Beiträge, Nutzer und Kategorien bleiben weiterhin bestehen!

Wichtig:

  • Jeder Nutzer muss sein Passwort neu vergeben.
  • Wählt dazu einfach "Ich habe mein Passwort vergessen".
  • Gebt die E-Mail-Adresse ein, mit der ihr registriert seid.
  • Ihr erhaltet eine E-Mail mit einem Link zur Passwortvergabe.
  • Bitte wählt ein neues (sicheres) Passwort und bestätigt den Vorgang.

Wir halten euch im angepinnten Beitrag auf dem Laufenden!

Mit vielen Grüßen
Euer ReportServer Team

#1 2018-12-11 17:21:40

FLU73
Member
Registered: 2018-10-25

date parameter with formula in UE language

Hello,

I'am trying to create a date parameter with formula, but it's not working as expected :

example #1:
${today == today.addYears(0).setMonth(12).setDay(11) ? today.addDays(-1) : today.addDays(1)}

which means :
if today_date = 11/12/2018
then 10/12/2018
else 12/12/2018

As current day is 11/12/2018, I am expecting to get the result 2018-12-10
but when executing, the returned value is 2018-12-12

I would like to try with :
${today == 2018-12-11 ? today.addDays(-1) : today.addDays(1)}
but I get an error "Cannot coerce '20181211' of class net.datenwerke.rs.utils.juel.wrapper.TodayWrapper to class java.lang.Long (incompatible type)"


example #2:
${today >= today.addYears(0).setMonth(12).setDay(15) ? today.firstDay() : today.lastDay()}
if today_date => 15/12/2018
then 01/12/2018
else 31/12/2018

I get the error : "lexical error at position 8, encountered invalid character '=', expected expression token"
operators like "=>" or ">=" or "ge" are not usable with dates ?
("ge" returns : Cannot compare 'class net.datenwerke.rs.utils.juel.wrapper.TodayWrapper' and 'class net.datenwerke.rs.utils.juel.wrapper.TodayWrapper')

As a newbie, I probably don't use the correct syntax, but I did not found examples on the forum or on other websites.

Offline

#2 2018-12-11 18:17:06

IF_Eduardo
Administrator
Registered: 2016-11-01
Website

Re: date parameter with formula in UE language

Hi FLU73,

please try with:
${today.equals(today.addYears(0).setMonth(12).setDay(11)) ? today.addDays(-1) : today.addDays(1)}

since today objects are dates, thus java objects, you cannot compare them with "==". Check here for more information:
https://www.admfactory.com/how-to-compa … s-in-java/

Regards,
Eduardo

Offline

#3 2019-01-03 18:01:03

FLU73
Member
Registered: 2018-10-25

Re: date parameter with formula in UE language

Hi Eduardo,

Thanks for the link, but it seems to not work.

I've used the code : ${(today).compareTo(today.addYears(0).setMonth(04).setDay(01)) == 0 ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

but when executing the query, I get the error : Method not found: class net.datenwerke.rs.utils.juel.wrapper.TodayWrapper.compareTo(net.datenwerke.rs.utils.juel.wrapper.TodayWrapper)

I wonder if date.compareTo() is found in the library, in the link they have :
package com.admfactory.date;
import java.text.SimpleDateFormat;
import java.util.Date;

Maybe something need to be added somewhere.

Offline

#4 2019-01-04 09:10:16

IF_Eduardo
Administrator
Registered: 2016-11-01
Website

Re: date parameter with formula in UE language

Hi FLU73,

please try with  ${today.getDate().compareTo(today.addYears(0).setMonth(4).setDay(01)) == 0 ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

Regards,
Eduardo

Offline

#5 2019-01-09 10:12:12

FLU73
Member
Registered: 2018-10-25

Re: date parameter with formula in UE language

Hi Eduardo,

Ok, it's fixed.
I tried what you suggested:
${today.getDate().compareTo(today.addYears(0).setMonth(4).setDay(01)) == 0 ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

Due to persistence of error message, I've replaced it by:
${today.getDate().compareTo(today.addYears(0).setMonth(4).setDay(01).getDate()) == 0 ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

it works fine with == operator, but not with <, or <=

Finally, it works with: lt, gt
${today.getDate().compareTo(today.addYears(0).setMonth(4).setDay(01).getDate()) lt 0 ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

or with: before, after
${today.getDate().before(today.addYears(0).setMonth(4).setDay(01).getDate()) ? today.addYears(-1).addMonths(0).addDays(0) : today.addYears(1).addMonths(0).addDays(0)}

Offline

Board footer

Powered by FluxBB