Campaign Expiration Date and Time configuration Issue(Though this would be easy)

We are having an issue where we want our campaign to run at 9am and set the expiration for End Of Day two weeks later. Since it appears you can not specify the end time, and 9am would be an awkward time to end a campaign, we are trying to find a way to have the Certification email template resolve the day before the expiration date, no time included.
For example, if the due date was the 29th at 9am, the email template would say something to the effect of “You have until the end of day on May, 28th to review and either approve, change…”.

I’ve tried all the code examples below (and more):

#set($oneDayBefore = $certification.expiration.minusDays(1)) $spTools.formatDate($oneDayBefore, "yyyy-MM-dd")
$spTools.formatDate($certification.expiration.minusDays(1), 2, 2)

#set($calendar = $spTools.toCalendar($certification.expiration))

$calendar.add(5, -1) ## Subtract 1 day (5 = Calendar.DATE)

#set($oneDayBefore = $calendar.getTime())

$spTools.formatDate($oneDayBefore, "MM/dd/yyyy")

I have been getting results like what is pictured below:



Does anyone know a code snippet I can use to provide the desired output? There has to be some way to request the DAY BEFORE the actual expiration. I thought it would be simple, but my smooth brain has yet to figure it out.

Alternatively, if someone knows a way to define the exact expiration time, that would also be a welcome solution.

Thanks

May be you can give this a try:

Convert the expiration Date to a Calendar
#set($cal = $spTools.toCalendar($certification.expiration))

Subtract one day (Calendar.DATE = 5)
$cal.add($cal.DATE, -1)

Extract the adjusted Date
#set($oneDayBefore = $cal.getTime())

Format as you like—e.g. “May 28, 2025”
$spTools.formatDate($oneDayBefore, “MMMM d, yyyy”)

Hey Sai,
Thanks for your response! Would I be embedding it in the email like this then?

#set($cal = $spTools.toCalendar($certification.expiration))
$cal.add($cal.DATE, -1)
#set($oneDayBefore = $cal.getTime())
$spTools.formatDate($oneDayBefore, “MMMM d, yyyy”)

So, it would literally read in the email like:

"you have until #set($cal = $spTools.toCalendar($certification.expiration))
$cal.add($cal.DATE, -1)
#set($oneDayBefore = $cal.getTime())
$spTools.formatDate($oneDayBefore, “MMMM d, yyyy”) to approve, change, or revoke… "