0

I am using the below AMPScript for getting the date and time -

If the "Appoint_DateTime" is set to 7/18/2016 4:00 PM, @FinalTime comes out as 4:0
I want it as 4:00 PM

How do I do it?

%%[
var @appoint, @Year, @Month, @Day, @FinalDate, @Hour, @Minute, @FinalTime, @test 
set @appoint = AttributeValue("Appoint_DateTime") 
set @test = DateParse(@appoint) 
set @Year = Datepart(Appoint_DateTime,"Y") 
set @Month = Datepart(Appoint_DateTime,"M") 
set @Day = Datepart(Appoint_DateTime,"D") 
set @FinalDate = CONCAT(@Month,"/",@Day,"/",@Year) 
set @Hour = Datepart(Appoint_DateTime,"H") 
set @Minute = Datepart(Appoint_DateTime,"MI") 
set @FinalTime = CONCAT(@Hour,":",@Minute)
]%%
0

You could do something like this using the format() function.

%%[
var @appoint, @finalTime
set @appoint = AttributeValue("Appoint_DateTime") 
set @finalTime = format(@appoint,"hh:mm tt")

]%%

@appoint: %%=v(@appoint)=%%
<br>@finalTime: %%=v(@finalTime)=%%
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.