How to record Web form entry date and time

Avatar

Avatar
Validate 1
Level 1
andreal38045380
Level 1

Likes

0 likes

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
andreal38045380
Level 1

Likes

0 likes

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
andreal38045380
Level 1

05-04-2018

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 50
Level 10
florentlb
Level 10

Likes

237 likes

Total Posts

1,109 posts

Correct reply

239 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 200
View profile

Avatar
Give Back 50
Level 10
florentlb
Level 10

Likes

237 likes

Total Posts

1,109 posts

Correct reply

239 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 200
View profile
florentlb
Level 10

18-04-2018

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

Answers (1)

Answers (1)

Avatar

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 4
davidl14970702
Level 4

Likes

30 likes

Total Posts

93 posts

Correct reply

13 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
davidl14970702
Level 4

04-02-2019

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