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

Question

Question

Forms Date Formatting via TEXT() Formula

asked on August 2, 2017

I'm not sure what I'm doing wrong, but in trying to format a date via the TEXT() formula in Forms, all I get is errors, e.g. "This field contains a calculation error", and below the formula, "Calculation does not contain the correct number of input parameters."

As with the other formulas in Forms, I would assume it follows conventional formatting, i.e. =TEXT(date, format). For example, I try =TEXT(NOW(),"yyyy-mm-dd") in Excel, LibreOffice, and Google Sheets and end up with the same value for each. In LF Forms, I get an error. Same goes for a date field substituted for NOW() in the example above.

Can anyone provide the correct syntax for this formula?

This is Forms 10.2.1.157

Thank you in advance!

1 0

Replies

replied on August 3, 2017

Hi Jesse,

The "TEXT" formula does not support format codes now. It could only be used to convert other type of variables to text variable, like =TEXT(1)

This is not quite useful and seems confusing. I have reported this to the team. Sorry for the inconvenience.

1 0
replied on January 13, 2020

Any word on if this is an upcoming feature? 

1 0
replied on November 22, 2022

Hi Rui - is this coming please? TEXT function in Forms still seems to be erroring.

0 0
replied on August 3, 2017 Show version history

Hello,

I would certainly look forward to codes being added to facilitate date formatting, and other number formatting for that matter; I seem to keep finding occasions where I would like to be able to do this, so now at least I know why I can't figure it out!

Thank you for the explanation.

1 0
replied on November 16, 2022

Hi there - we really need this feature in Forms advanced field calculations; it still seems to not be implemented?

We need to be able to express a date which is 01/01/2022 as "Jan 2022"; so am trying to use =TEXT(Invoice_Date,"mmm yyyy")

I get the same 'Calculation' errors as Jesse, even though that format works perfectly elsewhere, including Workflow.

Thanks.

0 0
replied on November 22, 2022

Hi Duncan,

We did not support that formula yet in latest release;

As for your case, I think it could be done with custom script like this:

Suppose the Invoice_Date field is a date field and you would like the value to be put on a single line field, then add "date1" as CSS class to the date field and "date2" as CSS class to the single line field, and add custom script:

$(document).ready(function(){
  $('.date1 input').on('change', function(){
    var dateValue = $('.date1 input').val();
    var dateFormat = $('.date1 input').attr('momentpattern');
    var dateUpdated = moment(dateValue, dateFormat).format('MMM yyyy');
    $('.date2 input').val(dateUpdated);
  });
});

It worked like this:

0 0
replied on November 23, 2022

Hi Rui, that's an excellent workaround, thanks!

 

I have made the changes - however we are seeing some difference and it's not quite working:

So for some reason it's not grabbing the year correctly - although the month is fine.

You can probably see that we are using dd/MM/yyyy format for our dates (being in NZ) so I wondered if that could that be the issue; but changing the Invoice Date format made no difference.

The code has been copy/pasted exactly as you have it in your example.

Any ideas why it might not be grabbing the year correctly?

Thanks again!

0 0
replied on November 23, 2022

Hi Duncan,

Can you try changing format('MMM yyyy') to format('MMM YYYY') and check if it works?

It seems that yyyy was not recognized in earlier version of Forms.

1 0
replied on November 23, 2022

Yes that's resolved it; thanks!

FYI and for anyone else finding this, the client is currently on Forms 11.0.2108.10347.

0 0
replied on January 7

Hi Rui - just a note that this CSS doesn't seem to work in Cloud. Have you been able to test that it works in Cloud or is there a tweak to how it is configured?

0 0
replied on January 7

Hi Duncan, I just tested it work if you use format('MMM YYYY') on Cloud.

0 0
replied on January 7

Hi Laserfiche team - any updates to this please? Do we still have to do Rui's workaround?

 

Just tried using the TEXT function in a Form's field formula with a date variable and still having issues. This time in LF Cloud.

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

Sign in to reply to this post.