Question: I have written an expression for a parameter default value in SSRS.

The expression is:

```
=Format(DateAdd(DateInterval.Day,Day(today()) * -1,DateAdd(DateInterval.Month,1,DateAdd(DateInterval.Year, -1, today()) ) ),"dd/MM/yyyy 23:59:59")

```

The plan is for the expression to return the date (UK time) of the end date of the month we're in now (e.g. July if running the report today) but giving me the previous, not current year.

so for example if I ran the report today I would see:

31/07/2020 23:59:59

or if running the report in September 2021 then:

30/09/2020 23:59:59

However when I added the expression I got this error message:

> 
> The property ‘DefaultValue’ of report parameter ‘date’ doesn't have
> the expected type. (rsParameterPropertyTypeMismatch)
> 
> 
> 

The data type I've chosen is 'Date Time' for this expression.

Does anyone have any pointers please as to how I can solve this error message riddle and get this expression working ?

Thanks

Answer: 
Unless you are trying to pass the date as a string (bad idea) then there is no need to format the date, especially as it will only be used as a parameter.

You could use this instead

**Edited - thanks to Hannover Fist for pointing out the original error**

```
=TODAY.AddDays(1 - TODAY.Day).AddMonths(1).AddYears(-1).AddSeconds(-1)

```

In order this reads:

* Get today = (2021-07-15 00:00:00)
* Subtract 14 days = (2021-07-01 00:00:00) -- based on today being the 15th
* Add 1 month = (2021-08-01 00:00:00)
* Subtract 1 year = (2020-08-01 00:00:00)
* Subtract 1 second = (2020-07-31 23:59:59)
Need to add CDATE function to convert the string to datetime, so:

```
=CDATE(Format(DateAdd(.... ,"dd/MM/yyyy 23:59:59"))

```