0

I currently have a page set up in CloudPages that includes a form. When someone fills out the form, the information goes into a saved data extension. Is there a way to automatically include the time that someone submitted the form to pull through into the data extension? This is my current AMPscript setup for bringing the filled out data into the extension:

%%[
set @A = RequestParameter(“A”)
set @B = RequestParameter(“B)


SET @InsertData = InsertData("XYZExtension", “A”, @A, “B”, 
 @B)

]%%

I've been looking online for a straightforward way to do this but haven't found anything.

Thanks!

2
  • 3
    This can be done without code. The following works in E,ail Studio, not contact builder. Add another field to your DE that has the type date, then a little plus symbol appears next to defaultValue. Press that to make the field use current Date as default value. you don't have to change the insert. Note this will be servertime, utc-6. Sep 29 at 15:36
  • Thank you Jonas! This did work, but I went with the solution below just to keep time consistent.
    – trh31625
    Sep 29 at 20:50
0

In addition to the clever and easy solution provided by Jonas in the comments, you can also use ampscript to do this for you:

%%[
set @systemDate  = Now(1)
set @localDate =  SystemDateToLocalDate(@systemDate)
set @A = RequestParameter("A")
set @B = RequestParameter("B")

set @InsertData = InsertData("XYZExtension", "A", @A, "B", 
 @B, "Inserted",@localdate)
]%%

The advantage of this solution is utilisation of SystemDateToLocalDate, ensuring the timestamp will be stored in your local time, instead of utc-6 (being the default system time zone)

3
  • Thank you Lukas! Although Jonas's solution worked, this is what I went with to avoid any timezone confusion. Works perfectly.
    – trh31625
    Sep 29 at 20:50
  • You’re welcome @trh31625 - remember to mark the answer as accepted Sep 30 at 4:05
  • Cool :) Just to give another side to this. I am a huge fan of keeping all times in DEs in servertime until you make them customer facing or export them. Firstly, this helps you leverage such quick fixes, but more importantly, only dates that you store in systemtime are consistent with the timestamps that you cannot influence in SFMC. -> consider: "is this timestamp newer than the customer's latest click?" >> this question is MUCH easier to answer if ALL times you store are systemTime, because dataviews like _click do. call your field "timestampSystemTime" and it's hard to miss. Sep 30 at 7:16

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.