This is a migrated thread and some comments may be shown as answers.

Default Date Values

3 Answers 749 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 May 2013, 07:51 AM
I am wanting to set 2 parameter values to the start of the previous month and the last day of the previous month

Can I build a new date in an expression? Something like   = new Date(Today().year, Today().Month, 1).AddMonths(-1)

3 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 16 May 2013, 08:38 AM
Hello,

You can achieve your goal by using the Date and Time functions available in our  expressions. For example, to set the default value to previous month you can use the following expression:

= Today().AddMonths(-1)

If generating the desired date requires more complex logic you can use an user function which returns the correct value.

Hope this helps.

Kind regards,
Chavdar
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Michael
Top achievements
Rank 1
answered on 16 May 2013, 09:13 AM
So to get the first and last dates of the previous month we could do something like
= (Today().AddDays(1-Today().Day)).AddMonths(-1)

?
1
Chavdar
Telerik team
answered on 16 May 2013, 03:52 PM
Hello,

Your expression is almost the correct one as it misses the cast to double for the AddDays method call. To get the first day of the previous month you can use the following expression:

= Today().AddDays(CDbl(1 - Today().Day)).AddMonths(-1)

and for the last day of the previous month:

= Today().AddDays(CDbl(- Today().Day))

Greetings,
Chavdar
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Michael
Top achievements
Rank 1
Share this question
or