DateTime variable format

Stimulsoft Reports.WEB discussion
Post Reply
eh13
Posts: 9
Joined: Wed Sep 15, 2021 2:06 am

DateTime variable format

Post by eh13 »

I'm trying to set a User Request DateTime type variable for my report

Code: Select all

report.Dictionary.Variables["OrderCreatedDat"].Value = order.CreatedDate.ToString();
When I do this i get an argument exception with the message Variable value '14/09/2021 10:32:56 AM' is wrong DateTime value.

I've also tried formatting the date to an ISO8601 standard string, but that gets me an error when compiling the report because there's no implicit conversion between 'System.DateTime' and 'string'.

How do I set this value?
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: DateTime variable format

Post by Lech Kulikowski »

Hello,

Please send us a sample that reproduces the issue for analysis.

Thank you.
eh13
Posts: 9
Joined: Wed Sep 15, 2021 2:06 am

Re: DateTime variable format

Post by eh13 »

I'm not setting this value in the report .mrt file, the example I included in the post is exactly what I'm doing. Stimulsoft.Report.StiReport type for the report object, and "order.CreatedDate" is a DateTime field.

I'm using the Designer v2021.3.1
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: DateTime variable format

Post by Lech Kulikowski »

Hello,

Please try to use the following code:
report.Dictionary.Variables["OrderCreatedDat"].ValueObject = order.CreatedDate;

Thank you.
eh13
Posts: 9
Joined: Wed Sep 15, 2021 2:06 am

Re: DateTime variable format

Post by eh13 »

When I do that I get:

error CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DateTime' and 'string'
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: DateTime variable format

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
eh13
Posts: 9
Joined: Wed Sep 15, 2021 2:06 am

Re: DateTime variable format

Post by eh13 »

When I passed the variable as type string insted, the field's Date Format still affected it as a string
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: DateTime variable format

Post by Lech Kulikowski »

Hello,

Please send us a sample that reproduces the issue for analysis.

Thank you.
Post Reply