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!

1
  • Yeah you need Apex.
    – Adrian Larson
    Dec 15, 2017 at 3:07

2 Answers 2

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.

1
  • 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, 2017 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .