You are viewing limited content. For full access, please sign in.

Question

Question

format a variable with an ISO date (in a form)

asked on February 28, 2024

Is there an easy way you can share?

Business Process Make a variable of the current date time (in the form) that is to be combined with other values in the form to create a unique key

I need to build a date time string like =TEXT(now(),"YYYY-MM-DD HH:mm:ss")
is there a way to accomplish that as a calculation in a variable?

I've tried to =concatenate(year,month,day hour,min,sec) all wrapping now() and the separators but its giving me a date like 2024-02-28 1:2:6 sigh... is there a better way?

 

I've been all through this, lots of examples but nothing on a plain vanilla datetime?

 https://doc.laserfiche.com/laserfiche.documentation/en-us/Subsystems/ProcessAutomation/Content/Forms-Current/Formulas.htm#Date/Tim

0 0

Answer

SELECTED ANSWER
replied on April 10, 2024

got it working but its brutal. This calculation in a single line test field will yield the current date time formatted "yyyy-MM-ddThh:mm:ss".

=CONCATENATE(YEAR(NOW()),"-",IF(MONTH(NOW())<10,CONCATENATE("0",MONTH(NOW())),MONTH(NOW())),"-",IF(DAY(NOW())<10,CONCATENATE("0",DAY(NOW())),DAY(NOW())),"T",IF(HOUR(NOW())<10,CONCATENATE("0",HOUR(NOW())),HOUR(NOW())),":",IF(MINUTE(NOW())<10,CONCATENATE("0",MINUTE(NOW())),MINUTE(NOW())),":",IF(SECOND(NOW())<10,CONCATENATE("0",SECOND(NOW())),SECOND(NOW())))

 

 

 

isodate.jpg
isodate.jpg (12.29 KB)
0 0

Replies

replied on June 27, 2024

Hi Sean, like you, I've been unable to make that Formatting work as you originally stated. I have created this formula which is shorter and not reliant on IF statements. Basically it pads each value with a 0 in the front of the number and then takes the Right 2 characters to always provide a 2 digit number

=CONCATENATE(YEAR(NOW()),"-",RIGHT(CONCATENATE("0",MONTH(NOW())),2),"-",RIGHT(CONCATENATE("0",DAY(NOW())),2),"T",RIGHT(CONCATENATE("0",HOUR(NOW())),2),":",RIGHT(CONCATENATE("0",MINUTE(NOW())),2),":",RIGHT(CONCATENATE("0",SECOND(NOW())),2))
 

0 0
replied on June 27, 2024

Hi Steve, thanks for this suggestion and its easier than my nested IF however, it does seem an unnecessary way to produce a standard formatted date.  Perhaps Laserfiche could consider this requirement as part of their "internationalisation" of the product, many of the recent improvements have been greatly appreciated.  If the TEXT() could accept formatting arguments that would be helpful.  In my attempts, I also tried a calculation rule - there is a function "DATE(2017, 1, 13)" returns "2017-01-13T00:00:00.000Z" but the input parameters only accept the date and we can't pass the time even though it's included in the output.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.