0

I have a landing page form in which I am passing value to a date field in Data Extension. Whenever a form is filled I want date and time to be captured. The date is captured correctly but the time always stays to '12:00:00 AM'.

Below is my AMPScript:

    %%[
var @EmailAddress,@date 

        set @EmailAddress = QUERYPARAMETER('key'),
        set @date = Format(Now(), "MMMM d, yyyy")

       ]%% 

HTML:

<input type="hidden" name="FechaDeCaptura" value="%%=v(@date)=%%" />

1 Answer 1

2

The formatDate function does remove the time aspects from the date. Since you have an input type below i believe that you have a form and a submit function which then takes this value and writes the Data to a DataExtension via UpdateData() or InsertData(). You just have to remove the formatDate function. If you not do this salesforce will default the time to 12:00:00AM (24h format = 00:00) which makes you see the result you have right now.

%%[
var @EmailAddress,@date

set @EmailAddress = QUERYPARAMETER('key')
set @date =  Now()

]%% 

<input type="hidden" name="FechaDeCaptura" value="%%=v(@date)=%%" />

On the form action page you will most likely have a function that takes the "FechaDeCaptura" parameter and uses this value inside one of the Data functions i mentioned on the top of this post.

When you would like to display the date like you formatted it somewhere you would just use:

%%=Format(@date, "MMMM d, yyyy")=%%
1
  • that worked well. Thanks a lot!
    – seeker
    Commented Jul 2, 2019 at 14:38

You must log in to answer this question.

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