-1

I am tr4ying to concatenate two date fields. But I'm getting this error: "Date expressions must use Integer or Long"

eg: System.debug(date.today()+date.today());

2 Answers 2

2

You need to provide Integer value of Long value to add to your Date.

For example - Date.today().addDays(1) or Date.today() + 1

I am not sure what you are actually trying to achieve here. Please provide more information if it doesn't help.

2

You can't directly add two dates together to get a String. You have to convert them to Strings first. By "adding" (+) almost any type to a String, that calls the toString method on the non-String operand, and the result is a String. The following example works:

System.debug(date.today()+''+date.today());

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .