You need to sign in to do that
Don't have an account?
ramm12
Need start date and End date
hi to all,
I have a retrieved week number from soql using aggregate result method.
For example January 10 menas it show WEEK 2.
I need to get start date and end date of the particular week 2
I dont want to use such as today function or date fields in formula or apex class.. I only need to get start date and end date using only the week number ?
Any help friends.......!
I have a retrieved week number from soql using aggregate result method.
For example January 10 menas it show WEEK 2.
I need to get start date and end date of the particular week 2
I dont want to use such as today function or date fields in formula or apex class.. I only need to get start date and end date using only the week number ?
Any help friends.......!
Try the below code snippet as reference:
string inputdate=system.today().format();
datetime startdate;
datetime enddate;
string startdatestring;
string enddatestring;
public void calculatedate(string inputdate)
{
string inputdatformat=string.valueof(date.parse(inputdate));
Datetime converttodatetime= datetime.valueOf(inputdatformat+' 00:00:00');
String strConvertedDate = converttodatetime.format('EEEE/MM/yyyy');
system.debug('################'+converttodatetime);
system.debug(strConvertedDate);
list<string> dayofcurrentday=strConvertedDate.split('/');
string dayofweek=dayofcurrentday[0];
integer i=1;
startdate=converttodatetime;
system.debug('################startdate'+startdate);
while(dayofweek!='Monday')
{
datetime newDate = converttodatetime.addDays(-i);
String strConvertedDate1 = newDate.format('EEEE/MM/yyyy');
list<string> dayofcurrentday1=strConvertedDate1.split('/');
system.debug(dayofcurrentday1);
dayofweek=dayofcurrentday1[0];
i=i+1;
startdate=newDate;
}
enddate=startdate.adddays(6);
startdatestring=startdate.format('dd/MM/yyyy');
enddatestring=enddate.format('dd/MM/yyyy');
system.debug('___startdatestring'+startdatestring+'____enddatestring'+enddatestring);
}
Ankit Gupta
try with DAY_IN_WEEK() function in soql..