number\integer function pelase

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MatLudlam
    Senior Member
    • Aug 2016
    • 288

    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
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    Don't see the need of this function, but you can create it, if you want

    Comment

    • MatLudlam
      Senior Member
      • Aug 2016
      • 288

      #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

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #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

        • MatLudlam
          Senior Member
          • Aug 2016
          • 288

          #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

          • tanya
            Senior Member
            • Jun 2014
            • 4308

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

            Comment

            • MatLudlam
              Senior Member
              • Aug 2016
              • 288

              #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

              • yuri
                Member
                • Mar 2014
                • 8511

                #8
                number\floor and number\ceil will be available in 4.9.0 version.
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                Working...