0

I'm trying to display a Date in a single input type textbox in Cloudpage, the data will be coming from Data Extension.

I tried changing the type to date : <input type="date" name="Baby_First_Birthday" data-field-type="Date">

But still its giving me a blank return, the value should be showing is the date from the DE.

1

For date formatting , you can follow link : AMPscript Date and Time Formatting

For display date in input type 'text' :

%%[
var @testDate, @DE_Date
set @DE_Date = "2012-10-05 03:21:34.567890"   /* date from DE */
set @testDate = FormatDate(@DE_Date, "dd/mm/yyyy")        
]%%

<input type="text" name="Baby_First_Birthday" value = "%%=v(@testDate)=%%"/>

OUTPUT : 05/10/2012 ('dd/mm/yyyy' format)

For display date in input type 'date' :

%%[
var @testDate, @DE_Date
set @DE_Date = "2012-10-05 03:21:34.567890"   /* date from DE */
set @testDate = FormatDate(@DE_Date, "yyyy-mm-dd")
]%%

    <input type="date" name="Baby_First_Birthday" value = "%%=v(@testDate)=%%"/>

OUTPUT : 10/05/2012 ('mm/dd/yyyy' format) (Firefox)

Note: There are some limitation with input type 'date' format.

For detail you can follow below mentioned link :

1. input type "date"

2. How to change input type=“date” format?

0

To display date from existing DE you need to access it first and then print in the desired place. If the attribute is available within subscriber context your code might look something like this:

%%[var @date

set @date = AttributeValue("You_Date_Attribute")

]%% 

<input type="date" name="Baby_First_Birthday" data-field-type="Date" value="%%=v(@date)=%%">

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.