# Calculate days remaining from today's date

**URL:** https://community.spicecrm.io/t/calculate-days-remaining-from-todays-date/255
**Category:** KReporter
**Created:** [February 20, 2018, 8:00pm UTC](https://community.spicecrm.io/t/calculate-days-remaining-from-todays-date/255 "2018-02-20T20:00:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jonnie00](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jonnie00](https://community.spicecrm.io/u/jonnie00)
#### Post date: [February 20, 2018, 8:00pm UTC](https://community.spicecrm.io/t/calculate-days-remaining-from-todays-date/255/1 "2018-02-20T20:00:31Z")

</div>

Hi,

I am trying to build a Kreport that provides a figure for ‘days remaining’ when today’s date is compared to a target date in the future. Can anyone tell me what the custom code would look like to do this?

Also, I don’t know if this is possible but I would like the days remaining figure to change colour when it reaches a certain threshold. Is this possible?

Any help gratefully received.

Many thanks

---

<div class="post-metadata">

### Author: ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)
#### Post date: [February 20, 2018, 10:37pm UTC](https://community.spicecrm.io/t/calculate-days-remaining-from-todays-date/255/2 "2018-02-20T22:37:05Z")

</div>

Jonnie,  
use CustomFunction manipulate tab  
In example below I display remaining days before opportunity closing date.  
I dragged field closed\_date twice. The second time I apply a custom SQL calculating the number of days remaining.

 ![CustomSQL02](https://canada1.discourse-cdn.com/flex030/uploads/spicecrm/original/1X/52ca1e6c69b22f0096fdf8ef1abbf654c18edfd7.PNG)

For color please check thread [Can we set color in field on the KReport?](http://community.spicecrm.io/t/can-we-set-color-in-field-on-the-kreport/180/2)

Val
