{"id":246,"date":"2020-09-18T09:39:55","date_gmt":"2020-09-18T09:39:55","guid":{"rendered":"http:\/\/basicwebsitesolutions.com\/blog\/?p=246"},"modified":"2020-09-18T09:39:55","modified_gmt":"2020-09-18T09:39:55","slug":"delphi-6-get-date-from-and-date-to-with-number-of-days","status":"publish","type":"post","link":"https:\/\/basicwebsitesolutions.com\/blog\/2020\/09\/18\/delphi-6-get-date-from-and-date-to-with-number-of-days\/","title":{"rendered":"Delphi 6 &#8211; Get Date From and Date To With Number of Days"},"content":{"rendered":"\n<p>So far I have recreated this code far more in the 16 years that I have been using Delphi. Just wanted to log it here so that when I need it again, it will be here.<\/p>\n\n\n\n<p>Hope it can also help other people<\/p>\n\n\n\n<p>Enjoy<\/p>\n\n\n\n<p>Coffee Cup<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>procedure TfrmPassword.BitBtn1Click(Sender: TObject);<br> var<br>   vWeekDay : String;<br> begin<br>   \/\/DateUtils<br> \/\/get the first and last day<br>   if (ALMONTH.VALUE &lt;= 11) then<br>   begin<br>     ALFROM.VALUE := StrToDate( ALMONTH.Text + &#8216;\/01\/&#8217; + ALYEAR.Text );<br>     ALTO.VALUE := StrToDate( IntToStr(ALMONTH.VALUE + 1) + &#8216;\/01\/&#8217; + ALYEAR.Text ) &#8211; 1;<br>   end<br>   else<br>   begin<br>     ALFROM.VALUE := StrToDate( &#8217;12\/01\/&#8217; + ALYEAR.Text );<br>     ALTO.VALUE := StrToDate( &#8217;01\/01\/&#8217; + inttostr(ALYEAR.Value + 1) ) &#8211; 1;<br>   end;<br> \/\/loop the number of days<br>   ALDAYS.VALUE := DaysBetween(ALTO.VALUE, ALFROM.VALUE) + 1;<br> ALDATE.VALUE := ALFROM.VALUE;<br>   ALSUN.VALUE := 0;<br>   ALTOTAL.Value := 0;<br> while (ALDATE.Value &lt;= ALTO.Value) do<br>   begin<br> <code>vWeekDay := LongDayNames[DayOfWeek(ALDATE.Value)]; if (vWeekDay = 'Sunday') then      ALSUN.VALUE := ALSUN.VALUE + 1 else ALTOTAL.Value := ALTOTAL.Value + 1; ALDATE.Value := ALDATE.Value + 1;<\/code><br> end;<br> end;<\/td><\/tr><\/tbody><\/table>\n","protected":false},"excerpt":{"rendered":"<p>So far I have recreated this code far more in the 16 years that I have been using Delphi. Just wanted to log it here so that when I need it again, it will be here. Hope it can also help other people Enjoy Coffee Cup procedure TfrmPassword.BitBtn1Click(Sender: TObject); var vWeekDay : String; begin \/\/DateUtils &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/basicwebsitesolutions.com\/blog\/2020\/09\/18\/delphi-6-get-date-from-and-date-to-with-number-of-days\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Delphi 6 &#8211; Get Date From and Date To With Number of Days&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[139,140,143,141,142],"class_list":["post-246","post","type-post","status-publish","format-standard","hentry","category-day-to-day-life","category-delphi-and-interbase","tag-delphi6","tag-get-date-from-to","tag-number-of-days","tag-start-date-and-end-date","tag-sunday-days"],"_links":{"self":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":1,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions\/247"}],"wp:attachment":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}