function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BehzadBehzad 

# of Days displayed

Hey guys,

 

I'm trying to add a number of days calculation in my Visualforce page, and this calculation is basically counting the number of days left to the end of a process.

 

I'm working with a date/time field, axns.Finish_date_time__c, so I use the ROUND() function to calculate the number of days only.

 

Here is the formula that I use to calculate the number of days left for my process:

 

ROUND(axns.Finish_date_time__c-DATEVALUE(NOW()),0)

 

This formula works well, but for some reason when it is equal to 10 days it shows the number in the following manner: 1E+1

 

 

Is there a way to display this number as 10?

 

 

Thank you,

 

Behzad

ocortinasocortinas

Did you try to use function "daysBetween"?

This return an integer when compare 2 Date variables, for example:

date startDate = date.newInstance(2008, 1, 1);
date dueDate = date.newInstance(2008, 1, 30);
integer numberDaysDue = startDate.daysBetween(dueDate);

In your case:

date startDate = axns.Finish_date_time__c;
date dueDate = DATEVALUE(NOW());
integer numberDaysDue = startDate.daysBetween(dueDate);

 

This works for you?

 

BehzadBehzad

Your sample code would work in the apex controller. 

 

But, I'm trying to perform this calculation on the client side, on my visualforce page.

 

 

Thanks,

 

Behzad

S_LieS_Lie
Change the #day to String . It should works