We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Linq + Dates

Are there standard function we can use on the template treated by linq reporting engine in order to deal with dates ?

Something like:
NOW() - Returns the current date and time.
YEAR(date) - Returns the year of specified date.
MONTH(date) - Returns the month of specified date.
DAY(date) …

Hi Simone,

Thanks for your inquiry.

Please check my reply here about formatting date. You can use SimpleDateFormat(“yyyy”) to get the year of date in DateUtil.reformat method. Please create methods like DateUtil.reformat to get the current date, month, day and year.

Hope this answers your query. Please let us know if you have any more queries.

Hi Simone,

Further to my last post, note that any Java class (including built-in) that conforms requirements described here can be used in expressions within square brackets. In general, you can use quite similar code within square brackets as you would use writing Java code with some limitations and differences. See this section for more information.

Regarding your request about date, you can use members of Date class just straight away. For example, given that date is a Date value, you can use the following template expression to output the date’s month:

The same story with a year, day, etc. To obtain and output the current date, you can use the following template expression:
<<[new Date()]:”dd.MM.yyyy”>>

Note that in case of invoking of static members and constructors, LINQ Reporting Engine must be made aware of the corresponding type (See Setting up Known External Types here for more information).

Please check following code example for your kind reference. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("<<[new Date()]:”dd.MM.yyyy”>>");
builder.writeln("<<[new Date()]:”dd”>>");
builder.writeln("<<[new Date()]:”MM”>>");
builder.writeln("<<[new Date()]:”yyyy”>>");
builder.writeln("<<[new Date().getMonth()]>>");

ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, "");

doc.save(MyDir + "Out.docx");

Thanks Tahir, that’s what i was looking for.


Hi Simone,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.