Date Parameter Defaults : 1st of Jan this year and 31st Dec this year?

0 Answers 74 Views
Report Parameters
Tommy
Top achievements
Rank 1
Iron
Iron
Iron
Tommy asked on 30 Jun 2022, 12:57 AM

I have StartDate and FinishDate paraemeters and I want their default to always be "this year" so StartDate would always be the 1st of Jan of the current year and FinishDate would be the 31st of Dec of the current year.

Is this possible with the date expressions?

Here are some example I have saved in my notebook but cannot figure out this new requirement :-)

First Day of Last Month

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

 

Last Day of Last Month

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

 

First Day of This Month

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

 

First Day of This Month Last Year

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

 

Last Day of This Month

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

Neli
Telerik team
commented on 04 Jul 2022, 10:03 AM

Hi Tommy,

To get the 1st of January of the current year, you can use the following expression:

= Date(Today().year, 1,1)

And for the last date:

= Date(Today().year, 12, 31)

No answers yet. Maybe you can help?

Tags
Report Parameters
Asked by
Tommy
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or