Results 1 to 3 of 3

Thread: imput date to determine day of the week

  1. #1
    s2000
    Guest

    Angry

    Alert! Damsel in distress!
    I'm having trouble with this someone please help me!

    This is the whole project - very confusing - any help?


    Perpetual Calendar Project


    Introduction

    The Gregorian calendar was introduced in 1582. You are being asked to write a program which calculates the day of the week for any date past and future, falling after 12/31/1582 to make a calendar for a specified month and year.

    Overview of the Problem
    a. Request the month, day, and year as numeric inputs. Use either single or multiple textboxes to capture the user’s inputs. Single text boxes make it necessary to parse the data to separate the month day and year but simplifies the user interface with the program.

    b. After you determine the maximum number of days in the month, check the user’s inputs for validity. If you determine an error in the input, notify the user with an error message or frowning face symbol and allow him to correct the errant month, day or year.
    The maximum number of days in each month is constant for all months except February, which is usually 28 days except leap years, when February has 29 days.

    A year is said to be a leap year if all of the following conditions are met.
    Any years divisible by 4 is considered a leap year, with the exception of those years divisible by 100 and not by 400. By this rule, the years 1600 and 2000 are leap years but the years 1700, 1800, and 1900 are not. If you are clever, this leap year condition can be tested with a single “If” statement. See chapter 5 of our textbook for more details on the “If” and the “Select Case”

    Algorithm

    Use the following algorithm to determine the day of the week for a given date.

    1) Treat January and February as the 13th and 14th months of the previous year, respectively. Thus, 1-10-98 is treated as 13-10-1997. Similarly, 2-10-1998 becomes 14-10-1997.

    2) Let m, d, and y denote the month, day, and year, respectively. Similarly,
    2-10-1998 becomes 14-10-1997. Compute w, where

    w = d + 2*m + Int((3/5)*(m +1)) + y + Int(y/4) – Int(y/100) + Int(y/400) + 2

    3) The remainder of w divided by 7 denotes the day of the week, where 0 is Saturday, 1 is Sunday, 2 is Monday, and so on. Hint : See the “Mod” function described on page 126 – Comment 8 of our text.


  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    You could use: -

    If Not IsDate(Indate) Then MsgBox "error"

    to check the date is valid and :

    Outday = WeekdayName(Weekday(Indate))

    will calculate the day of the week for any date.

  3. #3
    jim mcnamara
    Guest
    I've got some bad news. The Gregorian Calendar may have been officially adopted by the Church in 1582, but it required adding days to the calendar to make up for the fact that in 1582 the calendar was fast by about 15 days.

    Not every King/Queen or local tyrant bought into this idea. Therefore, the adoption of the new calendar occurred over 150 years, seemingly at random.

    A joke: if this is Alsace in March 5, 1661 then it's really February 20, 1661. This is why people born in Colonial America in the 1720's -1740's didn't really know when their birthday was because, in the Colonies, we didn't make the change until then. And it propagated very slowly. It messed everybody up, big time. George Washington's birthday is celebrated on the wrong day.

    The main reason people put off the change was that landlords would have to endure 15-17 extra off-the-calendar days to get the new calendar up to snuff.. ie., lose half a moth's rent. Landlords have political clout and fought the new calendar.

    Plus, basic calendric operations are available in lots of db's: Oracle handles dates & times back into BC, but ignores the country problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width