SSRS Default Date previous Year first day and last Day

Viewed 25

How do I get the first and last day of the previous year in SSRS for default dates tired wth DATEADD function but getting an error

2 Answers

You don't show what you tried so we can't explain what you are doing wrong.

If I needed to get the 1st day of the previous year, I would take the current year, subtract the number of days from 1 and then subtract a year.

With DATEADD, the first day of last would be:

=DATEADD("yy", 1, DATEADD("d", 1 - DATEPART("dy", TODAY), TODAY))

While the last day is actually simpler:

=DATEADD("d", 0 - DATEPART("dy", TODAY), TODAY)

You can use DATESERIAL() to do this easily

DateSerial just take 3 integer values (year, month, day) to return a date.

First day

=DateSerial( year(today()) - 1, 1, 1)

Last Day

=DateSerial( year(today()) - 1, 12, 31)
Related