How to match two dates

Stimulsoft Reports.NET discussion
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to match two dates

Post by Fabio Pagano »

I need to match a datetime field (from the dictionary) with a fixed date. Eg. MyDateFromDictionary >= "20111020". Script report is in C#.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to match two dates

Post by Alex K. »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to match two dates

Post by Fabio Pagano »

Sure. In my datasource i have a datetime column called "MyDate". In its field of the report, if "MyDate" is between two specific dates (eg. 01/01/2011 and 31/01/2011) i must print "x", else i must print "y".

I don't know how to create the IIF statement to see if the "MyDate" column is between the two fixed dates (i have tried several ways but with errors).

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How to match two dates

Post by HighAley »

Hello.
Fabio wrote:Sure. In my datasource i have a datetime column called "MyDate". In its field of the report, if "MyDate" is between two specific dates (eg. 01/01/2011 and 31/01/2011) i must print "x", else i must print "y".

I don't know how to create the IIF statement to see if the "MyDate" column is between the two fixed dates (i have tried several ways but with errors).
Please, try to use variables. See attached report template.

Thank you.
Attachments
1374.Report.mrt
(21.1 KiB) Downloaded 210 times
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to match two dates

Post by Fabio Pagano »

My intention was to write, in the field, the fixed value of the date, example:

{MyDate>"20111031" && MyDate<"20111001"?'Y':'X'}

but this raises the compilation error:

"Unable to apply operator "<" to operands of tpye "System.DateTime" and "string"."

This is correct, because the two operands are different: i have tried to convert one type to another but i have had other errors. So at this point i need to know how to convert the date in string or the string in date.

Thank you.

HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How to match two dates

Post by HighAley »

Hello.
Fabio wrote:My intention was to write, in the field, the fixed value of the date, example:

{MyDate>"20111031" && MyDatenew DateTime(2011,10,31) && MyDate < new DateTime(2011,10,01)?'Y':'X'}

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to match two dates

Post by Fabio Pagano »

I have tried, in a group footer, the following expression:

{Sum(Movimento.Movimento__Data_documento> new DateTime(2010,01,01) && Movimento.Movimento__Data_documento< new DateTime(2012,12,31)? 1 : 2)}

but the following error appears:

"The name "newDateTime" does not exists in the current context" (Note 1: i have translated the message from Italian - Note 2: in the error message, "newDateTime" appears without spaces).

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to match two dates

Post by Alex K. »

Hello,

Please send us your report with test data for analysis.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to match two dates

Post by Fabio Pagano »

I have sent the data and the report to support@stimulsoft.com.

Thank you.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

How to match two dates

Post by Andrew »

Thank you, Fabio.
Post Reply