Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

How to record Web form entry date and time

andreal38045380
Level 1
Level 1

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"/>

1 Accepted Solution
florentlb
Correct answer by
Level 10
Level 10

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

View solution in original post

2 Replies
florentlb
Correct answer by
Level 10
Level 10

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

View solution in original post

davidl14970702
Level 5
Level 5

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