The issue you're facing with the formula might stem from how the dtpstartdate is being referenced. When using formulas like dateadd(dtpstartdate.selecteddate(7), timeunit.days), it’s important to ensure that the syntax is correct and the dtpstartdate control is being properly referenced. The formula you're using seems to be incorrectly written, and that's why it's giving you an error.
The correct approach would be something like this:
DateAdd(dtpstartdate.SelectedDate, 7, TimeUnit.Days)
Here, dtpstartdate.SelectedDate gets the selected date from the dtpstartdate control. Then, DateAdd adds the specified number of days (7 in your case) to that date, with TimeUnit.Days defining that you're adding days.
Another key thing to check is whether the dtpstartdate control actually has a valid date. If the control is not initialized with a date or is left empty, that could lead to errors as well. Be sure that the date picker control is set with a valid date before attempting to use it in a formula.
Lastly, it's also essential to ensure that the environment you're working with (like PowerApps, Excel, or another platform) supports this syntax. Different platforms may have slightly different ways of handling date and time functions, so it's worth checking the documentation for the specific platform you're using.
If you're still running into trouble, it would be helpful to know the specific platform you're working with, and I can assist you further from there!