Create a string code based on current date and time which includes "0" digits, e.g. "0812" for 8h12

  • Asked
  • Active
  • Viewed 3837 times
0

Dear Open Foris team, I have a survey where I create a unique code based on the concatenation of the date and time. date_indiv: default value = idm:currentDate() time_indiv: default value = idm:currentTime() code: default value = concat(date_indiv,"-",time_indiv)

How can I modify my expression to obtain a code which includes "0", for example "0912" for 9h12: thus "20200604-0912". My current expression gives me "20200604-912"; so it seems to do it automatically for the date but not for the time.

Thanks a lot in advance, Bruno

0

Accepted answer

Hello,

For the same question I used the nexts expressions in the default value:

concat(substring(date,3,6),"_",time) apply when time>=1000;

concat(substring(date,3,6), "_0",time) apply when time>=100;

concat(substring(date,3,6), "_00",time) apply when time>=10;

where date is a field with default expression idm:currentDate() and time with idm:currentTime()

Lluís

0

Accepted answer

Thanks a lot for your speedy reply. It worked. Best wishes, Bruno

Your answer

Markdown text. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+E code, Ctrl+Shift+V paste as plain text. Tab indents list items and code; press Escape, then Tab, to leave the text box.

Insert an image

Say what the image shows, for people who can't see it.

Tip: type a few words from the error message, or put a tag in [brackets] to look only there.

Menu

Keyboard shortcuts

Anywhere

?
Show this list
/
Search
g h
Go to the home page
g q
Go to the questions
g t
Go to the tags
g u
Go to the users
a
Ask a question

Lists of questions

j k
Next or previous question
Enter
Open the question

Question pages

j k
Next or previous post

Shortcuts never apply while you type in a text field. Members can turn them off in their preferences.