Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Calculate the friday date of a given week


boywonder
 Share

Recommended Posts

Hello,

 

I have a scheduled finish date which can be any date m-f of a given week. However, I would like to return the friday date of the 'finish date' such that a pile of tasks are due in the week ending 6-Sep-06

 

Is there an easy way to do this?

 

thanks

Link to comment
Share on other sites

Well, how would you do it manually?

 

You'd add one day to the date if the current day of the week was Thursday, right? And two if the current day of the week was Wednesday, and so on?

 

DayOfWeek(FinishDate) will return 1 if FinishDate is Sunday, 2 if FinishDate is Monday, and so on; or, alternatively, DayName(FinishDate) will return the day of the week in words, "Sunday", "Monday", etc. Either of those functions, therefore, will give you what you need to know in order to know how many days to add to FinishDate to get to the next Friday, yes?

Link to comment
Share on other sites

I don't believe the rules have been addressed - if FinishDate is Friday, I assume you want that same day but if FinishDate is Saturday, what do you want? Well see if this works for you ... if Saturday, it kicks back to prior Friday and if Sunday it kicks forward to next Friday:

 

FinishDate + 7 - DayOfWeek ( FinishDate ) - 1

Link to comment
Share on other sites

I was sloppy. This is better: FinishDate - DayOfWeek ( FinishDate ) + 6

 

FinishDate - DayOfWeek ( FinishDate ) always backs to DayOfWeek 0 (which is the prior Saturday). Then jump forward to the DayOfWeek you want (in this case Friday ... or 6). smiley-laughing

Link to comment
Share on other sites

Thanks for all of the replys, I ended up doing it like this

 

Case(DayName(scheduledDelivery)="Monday";scheduledDelivery+4;

DayName(scheduledDelivery)="Tuesday";scheduledDelivery+3;

DayName(scheduledDelivery)="Wednesday";scheduledDelivery+2;

DayName(scheduledDelivery)="Thursday";scheduledDelivery+1;

DayName(scheduledDelivery)="Friday";scheduledDelivery)

 

My scheduled delivery calc already drops out the weekends so I don't have the Saturday issue.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use