Shop OBEX P1 Docs P2 Docs Learn Events
Day of the week calculation (from the julian day) — Parallax Forums

Day of the week calculation (from the julian day)

ArchiverArchiver Posts: 46,084
edited 2001-11-26 17:19 in General Discussion
Hi,
Does anyone know of a formula or algorithm to calculate the day of
the week from the julian day? I am familiar with the "doomsday"
algorithm and know the formula for that given the year.

any help would be appreciated.

Thanks,
RP

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-11-24 02:42
    http://www.emesys.com/BS2math4.htm

    Check out Tracy's site above all the Julian stuff you want and more much
    more!


    Original Message
    From: <rpsu279@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 23, 2001 6:20 PM
    Subject: [noparse][[/noparse]basicstamps] Day of the week calculation (from the julian day)


    | Hi,
    | Does anyone know of a formula or algorithm to calculate the day of
    | the week from the julian day? I am familiar with the "doomsday"
    | algorithm and know the formula for that given the year.
    |
    | any help would be appreciated.
    |
    | Thanks,
    | RP
    |
    |
    |
    | To UNSUBSCRIBE, just send mail to:
    | basicstamps-unsubscribe@yahoogroups.com
    | from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    |
    |
    | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    |
    |
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-24 04:35
    Oh, yeah! I've been there. Tracy's site is the best I've seen so far.
    I even have printouts of most of his stuff. I refer to it constantly.
    However, I could not find any mention of "day of the week" (Sunday,
    Monday, etc.) given the date (or julian date). I know he has code for
    finding out the month and day (value) from the julian day of the
    year.

    --- In basicstamps@y..., "Larry Gaminde" <lgaminde@t...> wrote:
    > http://www.emesys.com/BS2math4.htm
    >
    > Check out Tracy's site above all the Julian stuff you want and more
    much
    > more!
    >
    >
    >
    Original Message
    > From: <rpsu279@y...>
    > To: <basicstamps@y...>
    > Sent: November 23, 2001 6:20 PM
    > Subject: [noparse][[/noparse]basicstamps] Day of the week calculation (from the julian
    day)
    >
    >
    > | Hi,
    > | Does anyone know of a formula or algorithm to calculate the day of
    > | the week from the julian day? I am familiar with the "doomsday"
    > | algorithm and know the formula for that given the year.
    > |
    > | any help would be appreciated.
    > |
    > | Thanks,
    > | RP
    > |
    > |
    > |
    > | To UNSUBSCRIBE, just send mail to:
    > | basicstamps-unsubscribe@y...
    > | from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    > |
    > |
    > | Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    > |
    > |
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-24 16:39
    Are you using a RTC if so they have the Day 01 - 07, like the DS1302 !

    Original Message
    From: <rpsu279@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 23, 2001 8:35 PM
    Subject: [noparse][[/noparse]basicstamps] Re: Day of the week calculation (from the julian day)


    | Oh, yeah! I've been there. Tracy's site is the best I've seen so far.
    | I even have printouts of most of his stuff. I refer to it constantly.
    | However, I could not find any mention of "day of the week" (Sunday,
    | Monday, etc.) given the date (or julian date). I know he has code for
    | finding out the month and day (value) from the julian day of the
    | year.
    |
    | --- In basicstamps@y..., "Larry Gaminde" <lgaminde@t...> wrote:
    | > http://www.emesys.com/BS2math4.htm
    | >
    | > Check out Tracy's site above all the Julian stuff you want and more
    | much
    | > more!
    | >
    | >
    | >
    Original Message
    | > From: <rpsu279@y...>
    | > To: <basicstamps@y...>
    | > Sent: November 23, 2001 6:20 PM
    | > Subject: [noparse][[/noparse]basicstamps] Day of the week calculation (from the julian
    | day)
    | >
    | >
    | > | Hi,
    | > | Does anyone know of a formula or algorithm to calculate the day of
    | > | the week from the julian day? I am familiar with the "doomsday"
    | > | algorithm and know the formula for that given the year.
    | > |
    | > | any help would be appreciated.
    | > |
    | > | Thanks,
    | > | RP
    | > |
    | > |
    | > |
    | > | To UNSUBSCRIBE, just send mail to:
    | > | basicstamps-unsubscribe@y...
    | > | from the same email address that you subscribed. Text in the
    | Subject and
    | > Body of the message will be ignored.
    | > |
    | > |
    | > | Your use of Yahoo! Groups is subject to
    | http://docs.yahoo.com/info/terms/
    | > |
    | > |
    |
    |
    | To UNSUBSCRIBE, just send mail to:
    | basicstamps-unsubscribe@yahoogroups.com
    | from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    |
    |
    | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    |
    |
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-25 21:11
    >Hi,
    >Does anyone know of a formula or algorithm to calculate the day of
    >the week from the julian day? I am familiar with the "doomsday"
    >algorithm and know the formula for that given the year.
    >
    >any help would be appreciated.
    >
    >Thanks,
    >RP

    That's easy! You just divide the Julian day by 7 and look at the
    remainder. Say you count successive days from "1" on January 1,
    2001. That was a Monday. If you divide the Julian day by 7 and the
    remainder is one, that too is a Monday. 2=Tuesday etc. That goes if
    you continue the count on into years in the future.

    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-26 02:29
    That's only for this year, right?

    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > >Hi,
    > >Does anyone know of a formula or algorithm to calculate the day of
    > >the week from the julian day? I am familiar with the "doomsday"
    > >algorithm and know the formula for that given the year.
    > >
    > >any help would be appreciated.
    > >
    > >Thanks,
    > >RP
    >
    > That's easy! You just divide the Julian day by 7 and look at the
    > remainder. Say you count successive days from "1" on January 1,
    > 2001. That was a Monday. If you divide the Julian day by 7 and the
    > remainder is one, that too is a Monday. 2=Tuesday etc. That goes
    if
    > you continue the count on into years in the future.
    >
    > -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-26 16:38
    I was thinking of a way to do this using the different years also here is
    what I was thinking
    using the date from 1950 I think that's how far back Tracy's Julian stuff
    goes back to
    6-24-01 = 18438 Julian days 6-25-01 is 18439 pick a date that is before
    your last date needing to be checked and pick a day that is / 7 like 18210
    for example then using a for next loop like below you will check for
    remainder if there is a remainder the loop continues on until remainder = 0,
    when = to 0 then I will be how many days or group of 7 days from your
    starting point which you pick and know what day you started with then using
    a lookup table or something of you choice. this is not working code but I
    hope you can use the Idea I have not been working with the stamps for a few
    months so I'm a bit rusty on the code

    for i = 0 to 6
    day = (18438 - 18210) - i
    day = day //7
    if day > 0 next
    day += i
    Original Message
    From: <rpsu279@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 25, 2001 6:29 PM
    Subject: [noparse][[/noparse]basicstamps] Re: Day of the week calculation (from the julian day)


    | That's only for this year, right?
    |
    | --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    | > >Hi,
    | > >Does anyone know of a formula or algorithm to calculate the day of
    | > >the week from the julian day? I am familiar with the "doomsday"
    | > >algorithm and know the formula for that given the year.
    | > >
    | > >any help would be appreciated.
    | > >
    | > >Thanks,
    | > >RP
    | >
    | > That's easy! You just divide the Julian day by 7 and look at the
    | > remainder. Say you count successive days from "1" on January 1,
    | > 2001. That was a Monday. If you divide the Julian day by 7 and the
    | > remainder is one, that too is a Monday. 2=Tuesday etc. That goes
    | if
    | > you continue the count on into years in the future.
    | >
    | > -- Tracy
    |
    |
    | To UNSUBSCRIBE, just send mail to:
    | basicstamps-unsubscribe@yahoogroups.com
    | from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    |
    |
    | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    |
    |
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-26 17:02
    I have an Idea I was working on this is not workable code but the Idea is
    here

    using the Julian date formula of Tracy's you get a number starting I think
    in the year 1950. What I did was take a date that goes back as far as you
    last date needed, and get the Julian date for it like 18210 which needs to
    be divisible by 7, so taking the date 6-24-01 the Julian number is 18438
    minus your starting date 18210 ( you also need to know the day for this
    date ) then minus I ( I is number of days from your start point of Sunday or
    what ever day you pick ) then // 7 look for remainder. If remainder is = 0
    you have the same day as you start point plus I so I = day of week 0 =
    Sunday 1= Monday 2 = Tuesday and 6 = Saturday you could use a lookup table
    or just use the # to represent the day


    for I = 0 to 6
    day = ( Julian date(18438) - starting Julian date(18210) ) - I
    day = day //7 : look for remainder
    if day = 0 then I = to the day of the week 0 being Sunday or what ever it
    really works out to.


    Original Message
    From: <rpsu279@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 25, 2001 6:29 PM
    Subject: [noparse][[/noparse]basicstamps] Re: Day of the week calculation (from the julian day)


    | That's only for this year, right?
    |
    | --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    | > >Hi,
    | > >Does anyone know of a formula or algorithm to calculate the day of
    | > >the week from the julian day? I am familiar with the "doomsday"
    | > >algorithm and know the formula for that given the year.
    | > >
    | > >any help would be appreciated.
    | > >
    | > >Thanks,
    | > >RP
    | >
    | > That's easy! You just divide the Julian day by 7 and look at the
    | > remainder. Say you count successive days from "1" on January 1,
    | > 2001. That was a Monday. If you divide the Julian day by 7 and the
    | > remainder is one, that too is a Monday. 2=Tuesday etc. That goes
    | if
    | > you continue the count on into years in the future.
    | >
    | > -- Tracy
    |
    |
    | To UNSUBSCRIBE, just send mail to:
    | basicstamps-unsubscribe@yahoogroups.com
    | from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    |
    |
    | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    |
    |
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-26 17:04
    >That's only for this year, right?

    Hi Ravi,

    No, the Julian Day Number is sequential for a period of years. The
    base date for astronomers is 1 January 4713 BC on the Julian
    Calendar. Do you need to go that far back?! More convenient for a
    Stamp is a base date of January 1, 2001.

    Here is a subroutine that calculates the Julian Day Number from that
    date (1-Jan-2001, as day #1) to any other date in the 21st century up
    to Dec. 31, 2099. JD="day of year", JDN="days counted from 1/1/01"
    example 11/25/01 is JD=329, JDN=329
    example 11/25/99 is JD=329, JDN=36123


    ' returns Julian Day Number JDN for years 2001 to 2099
    ' Julian Day is sequential for current year.
    ' DD/MM/YY is day/month/year as integers (not BCD)
    julian:
    JD=MM-1*30+(MM/9+MM/2)-(MM max 3/3*(YY//4 max 1 +1))+ DD
    JDN=JD+(YY-1*365)+(YY-1/4)
    return

    That is the same as the routine on my web page
    <http://www.emesys.com/BS2math4.htm #JulianDate>, except there I used
    1950 as the base date and covered up to 2048. Had to cover Y2K then,
    back in the 20th century (hehe). To find the day of the week, divide
    the JDN by 7 and look at the remainder:
    DOW=JDN//7
    1=Monday, 2=Tuesday, 3=Wed. 4=Thurs 5=Fri 6=Sat 0=Sunday

    329//7 = 0 Sunday 25-Nov-2001
    36123//7 = 3 Wednesday 25-Nov-2099

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com


    >
    >--- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > > >Hi,
    > > >Does anyone know of a formula or algorithm to calculate the day of
    > > >the week from the julian day? I am familiar with the "doomsday"
    > > >algorithm and know the formula for that given the year.
    > > >
    > > >any help would be appreciated.
    > > >
    > > >Thanks,
    > > >RP
    > >
    > > That's easy! You just divide the Julian day by 7 and look at the
    > > remainder. Say you count successive days from "1" on January 1,
    > > 2001. That was a Monday. If you divide the Julian day by 7 and the
    > > remainder is one, that too is a Monday. 2=Tuesday etc. That goes
    >if
    > > you continue the count on into years in the future.
    > >
    > > -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-11-26 17:19
    Hi Tracy,
    Thanks again for your formula. I ran a program in regard to that and
    it works like a charm.

    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    >
    >
    > >That's only for this year, right?
    >
    > Hi Ravi,
    >
    > No, the Julian Day Number is sequential for a period of years. The
    > base date for astronomers is 1 January 4713 BC on the Julian
    > Calendar. Do you need to go that far back?! More convenient for a
    > Stamp is a base date of January 1, 2001.

    I don't need to go back at all. In fact, as long as it works for this
    year, it is good.


    >
    > Here is a subroutine that calculates the Julian Day Number from
    that
    > date (1-Jan-2001, as day #1) to any other date in the 21st century
    up
    > to Dec. 31, 2099. JD="day of year", JDN="days counted from 1/1/01"
    > example 11/25/01 is JD=329, JDN=329
    > example 11/25/99 is JD=329, JDN=36123
    >
    >
    > ' returns Julian Day Number JDN for years 2001 to 2099
    > ' Julian Day is sequential for current year.
    > ' DD/MM/YY is day/month/year as integers (not BCD)
    > julian:
    > JD=MM-1*30+(MM/9+MM/2)-(MM max 3/3*(YY//4 max 1 +1))+ DD
    > JDN=JD+(YY-1*365)+(YY-1/4)
    > return
    >
    > That is the same as the routine on my web page
    > <http://www.emesys.com/BS2math4.htm #JulianDate>, except there I
    used
    > 1950 as the base date and covered up to 2048. Had to cover Y2K
    then,
    > back in the 20th century (hehe). To find the day of the week,
    divide
    > the JDN by 7 and look at the remainder:
    > DOW=JDN//7
    > 1=Monday, 2=Tuesday, 3=Wed. 4=Thurs 5=Fri 6=Sat 0=Sunday
    >
    > 329//7 = 0 Sunday 25-Nov-2001
    > 36123//7 = 3 Wednesday 25-Nov-2099

    Great. That will work just fine.

    >
    > -- regards,
    > Tracy Allen
    > electronically monitored ecosystems
    > mailto:tracy@e...
    > http://www.emesystems.com
    >
    >
    > >
    > >--- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > > > >Hi,
    > > > >Does anyone know of a formula or algorithm to calculate the
    day of
    > > > >the week from the julian day? I am familiar with the "doomsday"
    > > > >algorithm and know the formula for that given the year.
    > > > >
    > > > >any help would be appreciated.
    > > > >
    > > > >Thanks,
    > > > >RP
    > > >
    > > > That's easy! You just divide the Julian day by 7 and look at
    the
    > > > remainder. Say you count successive days from "1" on January
    1,
    > > > 2001. That was a Monday. If you divide the Julian day by 7 and
    the
    > > > remainder is one, that too is a Monday. 2=Tuesday etc. That
    goes
    > >if
    > > > you continue the count on into years in the future.
    > > >
    > > > -- Tracy
Sign In or Register to comment.