#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default rounding dates

If would like a function that rounds a date to the nearest Monday. Is there
such a function?

Ellen
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default rounding dates

On Wed, 17 Oct 2007 03:22:03 -0700, ellebelle
wrote:

If would like a function that rounds a date to the nearest Monday. Is there
such a function?

Ellen


=A1-WEEKDAY(A1)+2+7*(WEEKDAY(A1)5)

If I understand you correctly, up through Thursday, the nearest Monday is the
Monday before; after Thursday, the nearest Monday is the Monday following.

If you want the split to be on a different day, then just change the 5 to
something else.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default rounding dates

One thought ..

Assuming source dates (real dates) running in A1 down
Put in B1:
=IF(A1="","",IF(WEEKDAY(A1,2)=1,A1,IF(ISNA(MATCH(W EEKDAY(A1,2),{2;3;4},0)),A1+VLOOKUP(WEEKDAY(A1,2), {5,3;6,2;7,1},2,0),A1+VLOOKUP(WEEKDAY(A1,2),{2,-1;3,-2;4,-3},2,0))))
Copy down as far as required. The expression "rounds down" Tues-Thurs to Mon
& "rounds up" Fri-Sun to the next Mon.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"ellebelle" wrote:
If would like a function that rounds a date to the nearest Monday. Is there
such a function?

Ellen

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default rounding dates

Thanks - this works brilliantly! I don't understand how it is doing it
though. Can you please tell me to use the same function to round to the
nearest Friday?

"Ron Rosenfeld" wrote:

On Wed, 17 Oct 2007 03:22:03 -0700, ellebelle
wrote:

If would like a function that rounds a date to the nearest Monday. Is there
such a function?

Ellen


=A1-WEEKDAY(A1)+2+7*(WEEKDAY(A1)5)

If I understand you correctly, up through Thursday, the nearest Monday is the
Monday before; after Thursday, the nearest Monday is the Monday following.

If you want the split to be on a different day, then just change the 5 to
something else.
--ron

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default rounding dates

On Wed, 17 Oct 2007 05:51:03 -0700, ellebelle
wrote:

Thanks - this works brilliantly! I don't understand how it is doing it
though. Can you please tell me to use the same function to round to the
nearest Friday?



=A1-WEEKDAY(A1)+6-7*(WEEKDAY(A1)<3)


The way this works is as follows:

A1-weekday(a1) always gives the Saturday prior to the date in A1.

That value + 6 will give the Next Friday.

Then we check the weekday of the original date, to decide if we want the next
Friday or the preceding Friday.

=============================================


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rounding UP Months' Difference between 2 dates FARAZ QURESHI Excel Discussion (Misc queries) 1 August 19th 07 10:29 AM
I need a formula with rounding up & rounding down to the nearest . Tony Kay Excel Worksheet Functions 3 May 29th 07 11:13 PM
Identifying unique dates within a range of cells containing dates cdavidson Excel Discussion (Misc queries) 0 October 12th 06 08:19 PM
Rounding Dates to the 1st? lawdoggy Excel Discussion (Misc queries) 3 February 14th 06 03:36 AM
Stop Excel Rounding Dates leinad512 Excel Discussion (Misc queries) 1 April 20th 05 04:19 PM


All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"