Presentation is loading. Please wait.

Presentation is loading. Please wait.

Date processing and conversion Please use speaker notes for additional information!

Similar presentations


Presentation on theme: "Date processing and conversion Please use speaker notes for additional information!"— Presentation transcript:

1 Date processing and conversion Please use speaker notes for additional information!

2 Julian Date The Julian Date is the year and the number of days that have passed so far in that year. If I look at the month of January, the date is simply the day of the month. January 12, 1999 would be 99/012 or 1999/012. February 12, 1999 is the 43rd day of the year because 31 days have already passed in January and this is the 12th day so it is 31 + 12. This is written as 99/043 or 1999/043. March 12. 1999 is the 71st day of the year because January (31 days) and February (28 days in a non leap year) have passed so it is 31 + 28 + 12 = 71 which is 99/071 or 1999/071. April 12, 1999 is the 102nd day of the year because January (31) + February (28) + March (31) means 31 + 28 + 31 + 12 = 103 which is 99/102 or 1999/102. December 12, 1999 is the 346 day of the year because Jan(31) + Feb(28) + Mar(31) + Apr(30) + May(31) + Jun(30) + Jul(31) + Aug(31) + Sep(30) + Oct(31) + Nov(30) + 12 days in Dec = 346 which is 99/346 or 1999/346. Putting this in a table or array: month = 1 days elapsed = 0 month = 2 days elapsed = 31 month = 3 days elapsed = 59 month = 4 days elapsed = 90 month = 5 days elapsed = 120 month = 6 days elapsed = 151 month = 7 days elapsed = 181 month = 8 days elapsed = 212 month = 9 days elapsed = 243 month = 10 days elapsed = 273 month = 11 days elapsed = 304 month = 12 days elapsed = 334 Note that the you only need to set up the days elapsed in the table/array. The month is the direct pointer/subscript/index that will retrieve the appropriate number of days from the table/array.

3 Purpose In this slide show, I will first start with December 31, 1999 and work backward to find how many days have elapsed between that date and a given date in the past. Next, I will start with January 1, 2000 and work forward to find how many days have elapsed between that date and a given date in the future. Finally, I will start with an arbitrarily chosen date, December 31, 2050 and move backward through both the twentieth and twenty first centuries. This lays the foundation for our work with dates. Frequently, when we work with dates we must find the number of days between two dates.

4 This is December 31, 1999 - the last day of the 1900s. It is a Friday. Let’s say I am looking for October 28, 1999. December 31, 1998 Days = 365 * (99-99) = 365 * 0 = 0 This deals with the number of whole years that have passed. Now I am at the last day of 1999 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 0 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 0 + (365 - (273 + 28)) Days = 0 + 64 = 64 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64. 64 Time Line 1999 Twentieth Century

5 This is December 31, 1999 - the last day of the 1900s. It is a Friday. Let’s say I am looking for October 28, 1998. December 31, 1998 365 Days = 365 * (99-98) = 365 * 1 = 365 This deals with the number of whole years that have passed. Now I am at the last day of 1998 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 365 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 365 + (365 - (273 + 28)) Days = 365 + 64 = 429 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64. 64 Time Line 19991998

6 Twentieth Century This is December 31, 1999 - the last day of the 1900s. It is a Friday. Let’s say I am looking for October 28, 1996. Dec 31, 1998 365 Days = 365 * (99-96) = 365 * 3 = 1095 This deals with the number of whole years that have passed. Now I am at the last day of 1996 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 1095 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 1095 + (365 - (273 + 28)) Days = 1095 + 64 = 1159 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64 plus the 1095 for the three years that have passed. 64 Time Line Dec 31, 1997 365 Dec 31, 1996 199919971998

7 Twentieth Century This is December 31, 1999 - the last day of the 1900s. It is a Friday. Let’s say I am looking for October 28, 1995. Dec 31, 1998 365 Days = 365 * (99-95) = 365 * 4 = 1460 This deals with the number of whole years that have passed. Now I am at the last day of 1995 and I need to calculate the number of days back to October 28th in that year. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 1460 + (365 - (273 + 28)) Days = 1460 + 64 = 1524 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64 plus the 1460 for the four years that have passed. Now I need to add in the leap year day in 1996. If 99 minus the year which in this case is 95 gives an integer answer when divided by 4, that integer answer is the number of leap years that are included. In this case it is 1, so I add 1 to the total. 1524 + 1 = 1525 64 Time Line Dec 31, 1997 365 Dec 31, 1996 199919971998 366 Dec 31, 1995 1996 (leap year)

8 Twentieth Century This is December 31, 1999 - the last day of the 1900s. It is a Friday. Let’s say I am looking for February 14, 1996. Dec 31, 1998 365 Days = 365 * (99-96) = 365 * 3 = 1095 This deals with the number of whole years that have passed. Now I am at the last day of 1996 and I need to calculate the number of days back to February 14th in that year. Days = What is already in days which in this case is 1095 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 1095 + (365 - (31 + 14)) Days = 1095 + 320 = 1415 There have been no leap years that have passed because it is only 3 years and 3 divided by 4 does not give an integer answer. However 1996 is evenly divisible by 4 which makes it a leap year and the day is prior to the 29th of Feb which is the leap year day so counting backwards Feb 29 is one of the days that needs to be counted. Therefore 1415 + 1 = 1416 Time Line Dec 31, 1997 365 Dec 31, 1996 1999199719981996 (leap year) 321

9 Twenty-First Century When we include the twenty-first century we can take a couple of approaches. We can establish a different end point, for example the last day of 2099 and work backwards in the same manner that we used for 1999. We can work forward to the dates that occur after the change of the century and backward to the dates that occur before the change of the century. In fact we can pick any date that we want and work backwards and forwards from that date. For example, we might pick the date the company was founded and move backwards and forwards depending on a comparison to that date. Both of these approaches require that we deal with a 4 digit year. Some solutions to the change in century limit the range of years to 100 and then only require a 2 digit year. For example: If the current year is 2001. We can decide to look at the next 50 years and the previous 50 years. We can determine that anything from 00 to 51 is dealing with the 21st century (20xx) and everything from 52 to 99 is dealing with the 20th century (19xx).

10 Twenty-First Century Jan 1, 2000 Days = 365 * (2000-2000) = 365 * 0 = 0 This deals with the number of whole years that have passed. No years have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 0 + 31 + 14 = 45 This is a leap year but moving forward, I encounter the date that I am looking for before I encounter the leap year day (February 29th), therefore the leap year day is not considered. I am looking for February 14, 2000

11 Twenty-First Century Jan 1, 2000 Days = 365 * (2000-2000) = 365 * 0 = 0 This deals with the number of whole years that have passed. No years have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 0 +273 + 28 = 301 This is a leap year but moving forward, I encounter the the leap year day (February 29th), therefore the leap year day before I encounter the day that I am looking for, therefore February 29th must be included in my count. Days = 0 + 273 + 28 + 1 = 301 I am looking for October 28, 2000

12 Twenty-First Century Jan 1, 2000 Days = 365 * (2001-2000) = 365 * 1 = 365 This deals with the number of whole years that have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 365 +273 + 28 = 666 2001 is not a leap year but the year that has passed, 2000 is a leap year because it is divisible by 4 so it must be counted - (actually with the a year that ends in 00, it must be divisible by 400). Therefore 666 + 1 = 667 I am looking for October 28, 2001Jan 1, 2001

13 Twenty-First Century Jan 1, 2000 Days = 365 * (2005-2000) = 365 * 5 = 1825 This deals with the number of whole years that have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 1825 + 273 + 28 = 2126 2005 is not a leap year but 2 of the years that have passed contain are leap years (2000 and 2004). You must therefore add 2 to the number of days count. 2126 + 2 = 2128 Note: In doing all of these calculations you need to make a decision about whether you are including both ends in your calculation or looking for days between which would not include both ends. In many of these calculations I have been inclusive - In other words I count the first day and I count the last day. I am looking for Oct 28, 2005 Jan 1, 2001Jan 1, 2002Jan 1, 2003Jan 1, 2004 20002001200220032004 Jan 1, 2005 2005

14 Twenty-First Century Jan 1, 2000 Days = 365 * (2004-2000) = 365 * 4 = 1460 This deals with the number of whole years that have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 1460 + 273 + 28 = 1761 2000 is a leap year so 1 must be added for that. 2004 is also a leap year and since the day is past February, we must add 1 for that leap year. 1761 + 1 + 1 = 1762 I am looking for Oct 28, 2004 Jan 1, 2001Jan 1, 2002Jan 1, 2003Jan 1, 2004 20002001200220032004

15 Twenty-First Century Jan 1, 2000 Days = 365 * (2004-2000) = 365 * 4 = 1460 This deals with the number of whole years that have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 1460 + 31 + 14 = 1505 2000 is a leap year so 1 must be added for that. 2004 is also a leap year but since the leap year day at the end of February has not yet been reached, no extra day is added. 1505 + 1 day for the year 2000 is 1505 + 1 = 1506 I am looking for Feb 14, 2004 Jan 1, 2001Jan 1, 2002Jan 1, 2003Jan 1, 2004 20002001200220032004

16 Twenty-First Century Jan 1, 2000 Days = 365 * (2008-2000) = 365 * 8 = 2920 This deals with the number of whole years that have passed. Days = Days calculated above that contain the days from whole years that have passed + (days passed in previous months + days passed in current month) Days = 2920 + 273 + 28 = 3221 2000 is a leap year so 1 must be added for that. 2004 is also a leap year that has been passed so 1 must be added for that. 2008 is a leap year and we are past the leap year day on Feb 29th so 1 must be added for that. 3221 + 1(2000) + 1(2004) + 1(2008) = 3224 I am looking for Oct 28, 2008 200020012002200320042005200620072008

17 Cross century December 31, 2005Looking for October 28, 2005 Days = 365 * (2005 - 2005) = 365 * 0 = 0 This deals with the number of whole years that have passed. Now I am at the last day of 2005 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 0 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 0 + (365 - (273 + 28)) Days = 0 + 64 = 64 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64. Saying there are three days left in October is not being inclusive. However if I am inclusive and include October 28th there is one more day.

18 Cross century This is December 31, 2005 Let’s say I am looking for October 28, 2004. December 31, 2004 365 Days = 365 * (2005-2004) = 365 * 1 = 365 This deals with the number of whole years that have passed. Now I am at the last day of 2004 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 365 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 365 + (365 - (273 + 28)) Days = 365 + 64 = 429 This makes sense because there are 3 days left in October, 30 days in November and 31 days in December which adds to 64. 64 Time Line 20052004

19 Twentieth Century This is December 31, 2005. Let’s say I am looking for October 28, 2002. Dec 31, 2004 366 Days = 365 * (2005 - 2002) = 365 * 3 = 1095 This deals with the number of whole years that have passed. Now I am at the last day of 2002 and I need to calculate the number of days back to October 28th in that year. Days = What is already in days which in this case is 1095 + the days in the current year minus the ones that have passed prior to the target date of October 28th. Days = Days calculated above that contain the days from whole years that have passed + (365 - (days passed in previous months + days passed in current month) Days = 1095 + (365 - (273 + 28)) Days = 1095 + 64 = 1159 In this example, one of the years that I have passed (2004) is a leap year. Therefore, I need to add 1 to the number of days making it 1160. 64 Time Line Dec 31, 2003 365 Dec 31, 2002 200520032004

20 Twentieth Century This is December 31, 2004 Let’s say I am looking for February 14, 1995 Dec 31, 2003 365 Time Line 302 20042003 I am looking for October 28, 2004. 365 2002 365 2001 366 2000 365 1999 365 1998 365 1997 366 1996 320 1995 Convert October 28 to days. Since it is a leap year and the leap year day is one of the days passed, it must be counted. Days1 = 273 + 28 + 1 = 302. Within 1995, convert backwards to February 14, 1995 calculating the number of days. This is not a leap year. Days2 = (365 - (days passed in previous months + days passed in current month) Days2 = 365 - (31 + 14) = 365 - 45 = 320. Calculate the number of years between which is 2004 - 1995 = 9. This subtraction does not actually give the number of years between excluding 2004 and 1995, so we must subtract 1 leaving 8 years (2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996). Determine which of these years is a leap year and which is not. Add 366 for the leap years and 356 for the non leap years. (2003=365, 2002=365, 2001=365, 2000=366, 1999=365, 1998=365, 1997=365, 1996=366. The total is 2922. This is added to the 320 which is the number of days in 1995 and 302 which is the number of days in 2004 to give the total number of elapsed days which is 3544.


Download ppt "Date processing and conversion Please use speaker notes for additional information!"

Similar presentations


Ads by Google