Apex: getting yesterday’s date

I know that you get today’s date like this: Date.today().
What would be the best solution to get yesterday’s date?

Answer

Just use addDays with a negative value:

Date.today().addDays(-1)

Attribution
Source : Link , Question Author : justasd , Answer Author : Jason Clark

Leave a Comment