I’m trying to get month from two date time values so that I can compare them in a <<if[]>> condition.
Using <<[new DateTime().Month]>> I am able to get “9” to output.
But if I try <<[startdate]>> – <<[startdate.Month]>> it only outputs the following:
9/6/2023 2:00:00 PM –
@airbags It is perfect that you managed to find a solution. Date value from JSON source is read as nullable DateTime? type. To use DateTime.Month property it is required to cast nullable DateTime? type to DateTime. For example see the following code:
string json = "{\"startdate\": \"2023-09-05T14:00:00Z\"}";
JsonDataSource jsonData = new JsonDataSource(new MemoryStream(Encoding.UTF8.GetBytes(json)));
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("<<[((DateTime)startdate).Month]>>");
ReportingEngine engine = new ReportingEngine();
engine.KnownTypes.Add(typeof(DateTime));
engine.BuildReport(doc, jsonData);
doc.Save(@"C:\Temp\out.docx");
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.