none
Getting number before decimal point in xsl

    Question

  • Hello guys,

    I have a number like 12.20. I want to write xsl statement, which will get only 12. Not the fraction. Can you guys let me know if you know anything how to write it.?

     

    Thanks

    • Moved by Mike Walsh FIN Friday, January 07, 2011 5:24 PM cust q (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Friday, January 07, 2011 5:17 PM

All replies

  • For that you would want to use the substring-before function.  Here's an example:

     

    <xsl:value-of select="substring-before(@NumberColumn, '.')"/>

    Let me know if you need more help.

    • Edited by iOnline247 Friday, January 07, 2011 7:58 PM edit code
    • Proposed as answer by Parvez Akkas Saturday, January 08, 2011 1:32 AM
    • Unproposed as answer by techneer Friday, January 14, 2011 5:41 PM
    Friday, January 07, 2011 7:57 PM
  • Hi,

    According to your description, I suggest that you can check this useful blog, it is similar to your problem:
    http://www.w3schools.com/xsl/el_decimal-format.asp
    I hope it can help you a little.

    Best regards,
    David Hu

     

    Tuesday, January 11, 2011 2:47 AM
  • I tried, but the problem is i need to multiply after decimal point with 60 and then show the value as AA:BB.

     

    consider 12.50 is the number then if take .50 and multiply with 60 it gives 3.0 right?

     

    so the value will 12:30. 

     

    SO for that I tried your thing, but the problem is the decimals are rounding of and giving me 13.30. And it is the same problem if numbers are negative.

    So i need the absolute number before decimal point.

    Friday, January 14, 2011 5:41 PM
  • There are many functions you can use to manipulate numbers/strings in XPath.  Look at floor(), round(), max() if you need absolute numbers.  I'm thrown off by your 13.30 because if you get 12 and add .50 * 60 to it, that's 15 not 13.30.  I'm not sure exactly what you are doing here...  

    By any chance are you manipulating time?

    Tuesday, January 18, 2011 12:56 AM