You need to sign in to do that
Don't have an account?
SalesRed
Display Day and Month values using 2 characters (if s single digit day or month)
Hello,
In my visualforce page I have the following line for displaying the day/month/year from a datetime field
{!DAY(DATEVALUE(quoteItem.Quoted_Date__c))}/{!MONTH(DATEVALUE(quoteItem.Quoted_Date__c))}/{!YEAR(DATEVALUE(quoteItem.Quoted_Date__c))}
if my day is the 3rd (i.e. 3), 4th etc (any single character less than 10) I wish to display 2 characters (i.e. a "0" before the day) on my page. SImilarly for months.
Does anyone know of the best way to do this?
Thanks in advance!
{!RIGHT(TEXT(DAY(DATEVALUE(quoteItem.Quoted_Date__c))+ 100), 2)}
All Answers
convert a integer which less than 99 to two chars:
String s = string.valueof(integer+100).right(2);
Hi Coco,
Thanks for your help. Can this be done in visualforce and not in the apex class?
Thanks.
RIGHT(TEXT(VALUE(your integer day) + 100), 2)
Hi Coco,
Thanks for your help.
On trying the following
{!RIGHT(TEXT(VALUE(DAY(DATEVALUE(quoteItem.Quoted_Date__c)))+ 100), 2)}
I get an error on saving it in eclipse as follows
"Save error: Incorrect parameter type for function 'VALUE()'. Expected Text, received Number"
Do you know what I may be putting wrong here?
Thanks.
{!RIGHT(TEXT(DAY(DATEVALUE(quoteItem.Quoted_Date__c))+ 100), 2)}
Great, thanks for your help. It works perfectly!