Date Function : IsGoodFriday


When I worked for an insurance company, Good Friday was a work day but not a business day. Only certain batch processes needed to run.


'*****************************************************************
'*  Function Name   : bIsGoodFriday                              *
'*  Created By      : Thomas A. Cassano                          *
'*  date            : 00/00/98                                   *
'*  Purpose         : Determines whether the day is Good Friday  *
'*  Arguments       : dCompare_date                              *
'*  Returns         : Boolean                                    *
'*  Comments        : None                                       *
'*****************************************************************
Function bIsGoodFriday(dCompare_date as date) as Boolean

   Dim iCurrent_Year             as Integer
   Dim a, b, c, d, e             as Integer
   Dim dEasterSunday             as date
   Dim dGoodFriday               as date
   Dim iDayOfEasterSunday        as Integer
   Dim iMonthOfEasterSunday      as Integer

   iCurrent_Year = Year(dCompare_date)

   a = iCurrent_Year Mod 19
   b = iCurrent_Year Mod 4
   c = iCurrent_Year Mod 7
   d = (19 * a + 24) Mod 30
   e = (2 * b + 4 * c + 6 * d + 5) Mod 7

   iDayOfEasterSunday = 22 + d + e

   iMonthOfEasterSunday = 3

   If iDayOfEasterSunday > 31 then
      iDayOfEasterSunday = d + e - 9
      iMonthOfEasterSunday = 4
   End If

   If iDayOfEasterSunday = 26 And iMonthOfEasterSunday = 4 then
      iDayOfEasterSunday = 19
   End If

   If iDayOfEasterSunday = 25 And iMonthOfEasterSunday = 4 And d = 28 And _
      e = 6 And a > 10 then
      iDayOfEasterSunday = 18
   End If

   dEasterSunday = DateSerial(iCurrent_Year, iMonthOfEasterSunday, _
                   iDayOfEasterSunday)

   dGoodFriday = DateAdd("d", -2, dEasterSunday)

   bIsGoodFriday = dGoodFriday = dCompare_date

End Function



Comments

  • date function

    Posted by Legacy on 10/10/2002 12:00am

    Originally posted by: pranay shrivastava

    nice job :0)
    

    • Finfing a code who return me 2 or 3 pay day in a month

      Posted by Astrisk on 06/08/2004 09:30pm

      The pay day is every 2 weeks, I'm looking for a function who can tell me how many pay we have in a month. The week of pay start sunday and finished saturday. We cant insert a start year in you what.

      Reply
    Reply
  • Visual Basic

    Posted by Legacy on 07/30/2002 12:00am

    Originally posted by: Paul Ms

    Very Good

    Reply
  • Need more optimised form

    Posted by Legacy on 07/08/2002 12:00am

    Originally posted by: sachin dayma

    need more optimised code

    Reply
  • Very Good

    Posted by Legacy on 01/24/2002 12:00am

    Originally posted by: Pradnya Jamgaonkar

    This program is very good . I am doing industrial training as a part of M.C.S. I can take take advantage of this code for my project.Thank U very much .
    PRADNYA

    Reply
  • good work

    Posted by Legacy on 01/12/2002 12:00am

    Originally posted by: Victor Basu

    Good work, it could be worthwhile in process of keeping appointment date.

    Victor

    Reply
  • Good

    Posted by Legacy on 06/28/2001 12:00am

    Originally posted by: Lenin

    Excellent!!

    Reply
  • 1

    Posted by Legacy on 06/02/2001 12:00am

    Originally posted by: Nanjar Budiman

    Code vb6
    

    Reply
  • bad one :-)

    Posted by Legacy on 02/15/2000 12:00am

    Originally posted by: horsEraser

    Dim a, b, c, d, e as Integer

    variable declaration will compile by VB like that
    dim a as variant ,b as variant , c as variant, d as variant
    dim e as integer
    on other way;
    dim a, b, c, d
    dim e as integer
    because variant is default datatype. (and stored memory 20 bytes and upper depend on variable data long) and if u use variant datatype you could not take any error messages. The Variant covers all data type.

    if u will use that a, b , c , d and e as integer, u have to write

    dim a as integer
    dim b as integer
    dim c as integer
    dim d as integer
    dim e as integer

    and other syntax ;
    dim a as integer, b as integer, c as integer, d as integer
    dim e as integer

    huh is it?
    you can test two ways declaration, breaking one point and use on debug window

    print typename(a)
    first wrong declaration input "variant" and first assigment on a as integer "integer" but not like integer has take memory 20 bytes for variant variable type and 2 bytes for integer.


    Reply
  • good one

    Posted by Legacy on 06/26/1999 12:00am

    Originally posted by: Siddharth Manohar

    Good one!! , it will be very helpful in insurance type of applications.

    Sidd

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Live Event Date: September 17, 2014 @ 12:00 p.m. ET / 9:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds