You could use the Apex addMonths() function to do this in your controller. Here is a snippet:
public Account a { get;set;}
public DateTime a3months {get;set;}
public testController(){
//I am querying the account just as an example to get the lastmodified date
a = [select id,lastmodifieddate from account limit 1] ;
//Here I use the addMonths() to increment the date field plus 3 months. Then you can display this field to your VF page.
a3months = a.lastmodifieddate;
a3months.addMonths(3);
}
You could use the Apex addMonths() function to do this in your controller. Here is a snippet:
public Account a { get;set;}
public DateTime a3months {get;set;}
public testController(){
//I am querying the account just as an example to get the lastmodified date
a = [select id,lastmodifieddate from account limit 1] ;
//Here I use the addMonths() to increment the date field plus 3 months. Then you can display this field to your VF page.
a3months = a.lastmodifieddate;
a3months.addMonths(3);
}
Right, which is why I had a link to this posting to help you perform additional formatting. It shows how to use some simple Date formulas in the VF page to assist with formatting.
You could use the Apex addMonths() function to do this in your controller. Here is a snippet:
public Account a { get;set;} public DateTime a3months {get;set;} public testController(){ //I am querying the account just as an example to get the lastmodified date a = [select id,lastmodifieddate from account limit 1] ; //Here I use the addMonths() to increment the date field plus 3 months. Then you can display this field to your VF page. a3months = a.lastmodifieddate; a3months.addMonths(3); }
All Answers
LastModifiedDate field is read-only. The system maintains that field. You could create a custom field of Date or DateTime to default to 3 month out.
Ohh I know that, just on my vf page I have to show the lastmodifieddate 3 months ahead of the dateitself... So I am changing it in the table...
So would you happen to know how to place it three months out on the VF page?
Thanks for replying so quickly..
You could use the Apex addMonths() function to do this in your controller. Here is a snippet:
public Account a { get;set;} public DateTime a3months {get;set;} public testController(){ //I am querying the account just as an example to get the lastmodified date a = [select id,lastmodifieddate from account limit 1] ; //Here I use the addMonths() to increment the date field plus 3 months. Then you can display this field to your VF page. a3months = a.lastmodifieddate; a3months.addMonths(3); }
Awesome so on my VF page would I say
<apex:outputText value="{!a3months}"/>???
Correct. And if you want additional date formatting in the VF page itself, check out this posting on how to use MONTH(), YEAR(), DAY() formulas in VF.
Thank you so much for helping me out it did work with the exception that it came out like this:
Mon Jun 08 23:15:16 GMT 2009
I tried
{0,{!a3months},MM/DD/YYYY} which change it to {0,6/8/2009,MM/DD/YYYY} ... How do I get rid of 0,...MM/DD/YYYY???
Right, which is why I had a link to this posting to help you perform additional formatting. It shows how to use some simple Date formulas in the VF page to assist with formatting.
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=10179