Default Date Values

4 posts, 0 answers
  1. Michael
    Michael avatar
    105 posts
    Member since:
    Nov 2010

    Posted 11 May 2013 Link to this post

    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)
  2. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 16 May 2013 Link to this post

    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.

  3. DevCraft banner
  4. Michael
    Michael avatar
    105 posts
    Member since:
    Nov 2010

    Posted 16 May 2013 Link to this post

    So to get the first and last dates of the previous month we could do something like
    = (Today().AddDays(1-Today().Day)).AddMonths(-1)

    ?
  5. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 16 May 2013 Link to this post

    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.

Back to Top