Announcement

Collapse
No announcement yet.

number\integer function pelase

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • number\integer function pelase

    Hi, can we have a number\integer function please. Right now I only have numbers less than 10, so using the substring function to just get the first 1 number is working.

    Thanks

  • #3
    Thanks for the response. I use the hosted version of Espo so cannot easily add my own function.

    Here is my specific use case:

    I want to generate quarter numbers on opportunities, things like "2017Q4" or "2018Q1" for example. Currently this is my code:
    Code:
    $tempMonth = datetime\month(closeDate);
    $qtr = ($tempMonth - 1)/3;
    $strQtr = string\substring($qtr, 0, 1);
    $numQtr = $strQtr + 1;
    closeQuarter = string\concatenate(datetime\year(closeDate),"Q",$numQtr);
    I currently have to use string\substring() function to perform the integer calculation. Is there a better way?

    There are other places where integer is needed too. Happy to list them if it helps.

    Thanks.

    Comment


    • #4
      You can concatenate with a number
      Code:
      $tempMonth = datetime\month(closeDate);
      $qtr = ($tempMonth - 1)/3 + 1;
      closeQuarter = string\concatenate(datetime\year(closeDate), "Q", $qtr);
      this works as well

      Comment


      • #5
        That is what I started with. For the date of 25th May 2020, the quarter number comes out as "2020Q2.3333333333333". It is probably ok for the first month in any quarter because 0/3 has no decimal component.

        Thanks.

        Comment


        • #6
          Possible this function will be added or be improved 'round' function

          Comment


          • #7
            I did initially look at "round()", and could make it work in this specific situation by adjusting the maths, but decided substr would be easier.

            If it could be implemented that would be great, especially as there is a 1 to 1 mapping to an underlying PHP function, should be easy.

            Thanks.

            Comment


            • #8
              number\floor and number\ceil will be available in 4.9.0 version.

              Comment

              Working...
              X