Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


2012/12/3 Dennis E. Hamilton <dennis.hamilton@acm.org>:
You should get a lot of responses on this.


Actually, I responded quite a few times, but unfortunately I forgot
(as usual) about the ”new” nad odd behaviour of this list, so I only
responded directly to the OP. That was not my intention, though, so
here is a short summary, just in case someone happens to be
interested:

A1: Year
B1: =IF(WEEKDAY(DATE(A1;10;31);2)<4;4;11)-WEEKDAY(DATE(A1;10;31);2)+21

The WEEKDAY thing is always calculated twice, which could feel a bit
unnecessary. Could be avoided by using a cell for subtotal:

A1: Year
B1: WEEKDAY(DATE(A1;10;31);2)
C1: =IF(B1<4;4;11)-B1+21

Here's a macro that does the whole thing:
REM ***** BASIC *****

Function Thanksgiving(Year As Long) As Date
Dim DayOfWeek As Long

DayOfWeek=WeekDay(DateSerial(Year,10,31))
If DayOfWeek<5 Then
Thanksgiving=DateSerial(Year,11,26-DayOfWeek)
Else
Thanksgiving=DateSerial(Year,11,33-DayOfWeek)
EndIf
End Function

REM ***** END OF BASIC *****
A1: Year
B1: =THANKSGIVING(A1)






US Thanksgiving is always the 4th Thursday in November.

So, the first thing you want to do is find out what day of the week November 1, yyyy, in a 
particular year is. (There are functions for this).

I found the whole thing a bit easier if I started by finding out the
weekday of 31 October, but I guess it's just another way of doing it.



Then find out how many days later the first Thursday is.  (In 2012, the answer is 0.)  You'll 
have to work this out based on how day-of-week is counted.

Add that number of days and 21 more to the November 1, yyyy date value.  That will show you the 
date of Thanksgiving in year yyyy.  (For 2012, the correct answer is November 22, 2012.)

 - Dennis

-----Original Message-----
From: . [mailto:Look@eBookRing.net]
Sent: Monday, December 03, 2012 02:59
To: users@global.libreoffice.org
Subject: [libreoffice-users] Calc formula for US Thanksgiving date

I need a formula for Calc to determine the US Thanksgiving date for a
given year.

Thanks

--
www.eBookRing.net

The designer and maker of the original eBookRing
The perfect stand for eReaders, iPads, iPhones, tablet computers and other electronic devices.

Patent Pending


--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted


--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.