How to record Web form entry date and time | Community
Skip to main content
New Participant
Apr 6, 2018 12:56 AM UTC
Solved

How to record Web form entry date and time

Hi,

I am building a Web form to collect some data from users and I want to record the creation time of each form entry.

I created a field with type "datetimenotz" in the schema and I have issues storing the datetime value into it.

May I know what is the expected input type and format of the SQL data type "datetimenotz"?

JS script to run after form submission and before Storage:

function getUTCDate() {

    var date = new Date(Date.now());

    return pad("00", date.getUTCDate()) +

      '/' + pad("00", (date.getUTCMonth() + 1)) +

      '/' + date.getUTCFullYear() +

      ' ' + pad("00", date.getUTCHours()) +

      ':' + pad("00", date.getUTCMinutes()) +

      ':' + pad("00", date.getUTCSeconds());

  }

  function pad(pad, str) {

    if (typeof str === 'undefined') {

      return pad;

    } else {

      return (pad + str).slice(-pad.length);

    }

}

ctx.my_schema.@datetime = getUTCDate();

Error message:

TIM-030009 Date '05/04/2018 05:55:17': invalid character at position 5 ('4') Invalid type for value '05/04/2018 05:55:17' from element '@datetime' (document of type 'somenamespace:my_schema'). XSV-350023 Unable to save document of type 'somenamespace:my_schema'. SOP-330011 Error while executing the method 'Write' of service 'xtk:persist|xtk:session'.

Source schema:

<attribute advanced="false" label="datetime" name="datetime" sqlname="datetime"

               type="datetimenotz"/>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
florentlb
florentlbAccepted solution
Level 10
Apr 18, 2018 3:51 PM UTC

Hi,

Have you checked this page? Depending on the type of database you use, there might be some slight differences for the types of data to use.

https://docs.campaign.adobe.com/doc/AC/en/CFG_Schema_Reference_Schema_structure.html

Florent

2 replies

davidl14970702
Level 4
Feb 4, 2019 8:07 PM UTC

I ran into a similar issue.

When I changed my code this it worked.

var date = formatDate(getCurrentDate(),"%4Y/%2M/%2D %02H:%02N:%02S")

This is the link to the documentation from the JSAPI

getCurrentDate

Translate
florentlb
florentlbAccepted solution
Level 10
Apr 18, 2018 3:51 PM UTC

Hi,

Have you checked this page? Depending on the type of database you use, there might be some slight differences for the types of data to use.

https://docs.campaign.adobe.com/doc/AC/en/CFG_Schema_Reference_Schema_structure.html

Florent

Translate