Question: I have a SQL query which is returning output; I need to get substring with last occurrence, I am confused and not able to find out how to do that:

```
SELECT
    spsetuppath,
    SUBSTRING(spsetuppath, 0, (LEN(spsetuppath) - CHARINDEX('\', RTRIM(LTRIM(REVERSE(spsetuppath))))) + 1)
FROM
    UMRdb..sql_spversion 
WHERE
    bitversion = '64' 
    AND productversion = ' 10.50.2500.0'

```

Output of this command is as follows

[![enter image description here](https://i.stack.imgur.com/oieWG.png)](https://i.stack.imgur.com/oieWG.png)

For the last column, I need the path before exe and I need only exe file name - how to do that?

So output I am expecting should look like this 

```
SQLServer2008R2SP1-KB2528583-x64-ENU.exe

```

Answer: 
If you need your action in client side Use following Jquery function :

```
<div class="form-group">
     <?php
      $data = array('name' => 'Basicvalue','value' => set_value('Basicvalue'),'id'=>'Basicvalue',  'class' => 'form-control changetodecimal' ,'readonly' => 'true');
    echo form_input(($data));
      ?>
  </div>  

<script>
$(document).on('change',".changetodecimal", function(){ 
    var inputvalues = $(this).val();
    var resultvalues=parseFloat(inputvalues).toFixed(2); 
    $(this).val(resultvalues);

});
</script>

```

If you want Server Side (PHP) use following function :

```
echo number_format($number, 2);

```
Use number\_format($yournymber,2);

```
<?php
    $num=3;

    $decimalNum=number_format($num,2);

    echo $decimalNum;
?>

```

You will get the output 3.00