You need to sign in to do that
Don't have an account?
abinaya
how to get the selected day in the given date range
Hi all,
How to get the selected day dates in the a given date range. For eg: i am selecting the date range from nov 1st to nov 30th. In this date range i want to get the monday date's i.e nov 2nd, nov 9th, etc.
Also i want to check a condition in soql like createddate day is equal to monday .
Kindly help me in this.
Regards,
Abinaya.
How to get the selected day dates in the a given date range. For eg: i am selecting the date range from nov 1st to nov 30th. In this date range i want to get the monday date's i.e nov 2nd, nov 9th, etc.
Also i want to check a condition in soql like createddate day is equal to monday .
Kindly help me in this.
Regards,
Abinaya.
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", 6 ,"Saturday" )
Note that this formula only works for dates after 01/07/1900. If you’re working with older dates, use the same process with any Sunday prior to your earliest date (e.g. 01/05/1800).
You can also adjust this formula if your week starts on a different day. For example, if your week starts on Monday, you can use January 8, 1900 in your condition. The new formula looks like this:
or you can us the same in apex code like this
date StartDate = date.newInstance(1900, 1, 8);
date Todaydate = system.today();
Integer numberDaysDue = startDate.daysBetween(Todaydate);
Integer x = math.MOD( numberDaysDue , 7 );
system.debug('$!@%#$!@%#'+ x);
like it return 1 as its tuesday
All Answers
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", 6 ,"Saturday" )
Note that this formula only works for dates after 01/07/1900. If you’re working with older dates, use the same process with any Sunday prior to your earliest date (e.g. 01/05/1800).
You can also adjust this formula if your week starts on a different day. For example, if your week starts on Monday, you can use January 8, 1900 in your condition. The new formula looks like this:
or you can us the same in apex code like this
date StartDate = date.newInstance(1900, 1, 8);
date Todaydate = system.today();
Integer numberDaysDue = startDate.daysBetween(Todaydate);
Integer x = math.MOD( numberDaysDue , 7 );
system.debug('$!@%#$!@%#'+ x);
like it return 1 as its tuesday
Very usefull and nicely written code, thanks for the effort but i belive the question is getting "selected day in the given date"
for example if i pass today date it return "Tuesday" as today is tuesday
the code you have mentioned above will formate the data and chagne it to 24 Nov 2015 , if i enter 24/11/2015 as input
i let me know if i miss undersatnd the question