0

I need to populate Last week, Last two weeks, current Month dates in Visualforce Component, how can I do that.

 <apex:outputText value="{0, date, MMMM d','  yyyy}">
 <apex:param value="{!Today()}" />
 </apex:outputText>

This would give me todays date. But I need last week date range, or atleast start of last week, and last two weeks. if we cannot achieve this is the visualforce component, we can try some logic in apex controller as well. Any suggestions. Thanks!

0

This here may help also to point you in the right direction if you want to define a range a week or 2 weeks previous to the result in the formula you will find Here in the answer to this question.

| improve this answer | |
  • 1
    FYI you can vote for a post to be a duplicate of another. This answer doesn't really add much value, but that flag would. – Adrian Larson Dec 15 '17 at 18:23
0

got it was able to achieve it using below code in apex controller:

public string getDate(){ 
Date d = System.Today(); 
Datetime dt = d.toStartofWeek() - 7;
String LastWeek = dt.format('MM-dd-yyyy');  
return LastWeek ; 
}

Visualforce:

<li> {!date1} Last Week</li>

couldn't format date class in Visualforce.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.