--- title: "Days between Two Dates" id: 79481 type: "computer_media" slug: "days-between-two-dates" url: "http://localhost/computer_media/days-between-two-dates/" markdown_url: "http://localhost/computer_media/days-between-two-dates.md" published_at: "2026-11-22T14:40:53+00:00" modified_at: "2026-11-22T14:40:53+00:00" featured_image: url: "http://localhost/wp-content/uploads/2026/11/days-between-two-dates-1.png" excerpt: "Counts the days between two dates on the ZX81 or TS1000." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" model: - name: "Sinclair ZX81" slug: "zx81" taxonomy: "model" url: "http://localhost/model/zx81/" - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" indiv: - name: "Ronald Paludan" slug: "ronald-paludan" taxonomy: "indiv" url: "http://localhost/indiv/ronald-paludan/" genre: - name: "Calendar" slug: "calendar" taxonomy: "genre" url: "http://localhost/type/calendar/" media_type: "Program" programmers: - name: "Ronald Paludan" slug: "ronald-paludan" taxonomy: "indiv" url: "http://localhost/indiv/ronald-paludan/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Days%20between%20Two%20Dates%20%281983%29%28Paludan%2C%20Ronald%29%28TS1000%29%28US%29%28Program%29.zip" mediadate: "1983" images: - url: "http://localhost/wp-content/uploads/2026/11/days-between-two-dates-1.png" - url: "http://localhost/wp-content/uploads/2026/11/days-between-two-dates-2.png" - url: "http://localhost/wp-content/uploads/2026/11/days-between-two-dates-3.png" article_media: - id: 43579 title: "Calculating the Days" type: "article" url: "http://localhost/article/calculating-the-days-2/" - id: 24465 title: "Calculating the Days" type: "article" url: "http://localhost/article/calculating-the-days/" media_type_tags: "Calendar" license: false --- # Days between Two Dates Counts the days between two dates, allowing for leap years and for the century years that are not leap years. RUN it and enter month, day and four-digit year for each date, earlier date first. The second year can be up to 88 years after the first; for longer spans add two runs together, as the article explains. ENTER repeats, and any other entry quits. The article gives 1K as the memory needed, but this listing is 1252 bytes before its variables and screen, so it needs 2K. Its example of July 7, 1881 to January 1, 1921 is a day too high: the program correctly prints 14422, because 1900 was not a leap year. Reprinted from [SYNC, January/February 1983](https://timexsinclair.com/article/calculating-the-days/). Published in LISTing February 1989 ([Calculating the Days](https://timexsinclair.com/article/calculating-the-days-2/)). ## Source Code ``` 20 DIM N(12) 25 LET N(1)=0 30 LET N(2)=31 35 LET N(3)=59 40 LET N(4)=90 45 LET N(5)=120 50 LET N(6)=151 55 LET N(7)=181 60 LET N(8)=212 65 LET N(9)=243 70 LET N(10)=273 75 LET N(11)=304 80 LET N(12)=334 85 LET D=0 90 PRINT " M/D/Y" 100 PRINT "ENTER FIRST DATE: "; 110 INPUT M1 112 IF M1>12 THEN GOTO 110 120 PRINT M1;"/"; 130 INPUT D1 132 IF D1>31 THEN GOTO 130 140 PRINT D1;"/"; 150 INPUT Y1 160 PRINT Y1 170 PRINT "ENTER SECOND DATE: "; 180 INPUT M2 185 IF M2>12 THEN GOTO 180 190 PRINT M2;"/"; 200 INPUT D2 205 IF D2>31 THEN GOTO 200 210 PRINT D2;"/"; 220 INPUT Y2 225 IF Y2-Y1>88 OR Y22 THEN LET D=D-1 285 IF INT (Y2/100)*100=Y2 AND INT (Y2/400)*4002 THEN LET D=D+1 300 LET D=D-N(M1)-D1 310 LET D=D+N(M2)+D2 315 IF Y1=Y2 THEN LET D=D-365 320 PRINT D;" DAYS APART" 330 INPUT Y$ 340 CLS 350 IF Y$="" THEN GOTO 20 ```