{"id":447,"date":"2022-01-26T11:27:46","date_gmt":"2022-01-26T08:27:46","guid":{"rendered":"https:\/\/mryed.com\/?p=447"},"modified":"2022-01-26T11:27:48","modified_gmt":"2022-01-26T08:27:48","slug":"tarih-farki-hesaplama","status":"publish","type":"post","link":"https:\/\/mryed.com\/en\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/","title":{"rendered":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama"},"content":{"rendered":"<p>Python ile belirtilen iki tarih aras\u0131ndaki g\u00fcn fark\u0131n\u0131 hesaplad\u0131k. Yine belirtilen saat ile de aradaki saat fark\u0131n\u0131 bulduk. Bu fark bulma i\u015fleminde <em><a href=\"https:\/\/mryed.com\/en\/yazilim\/kodlama\/artik-yil-hesaplama-python\/\">art\u0131k y\u0131lda<\/a><\/em> dikkate al\u0131nm\u0131\u015ft\u0131r.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\" id=\"python-2-tarih-arasindaki-fark\">Python 2 Tarih Aras\u0131ndaki Fark<\/h2>\n\n\n\n<p>tarih_1 ve tarih_2 de\u011fi\u015fkenleri ile tarih ve saat giriyoruz. \u0130stenirse input ile bu bilgiler kullan\u0131c\u0131dan da al\u0131n\u0131r. Daha sonra bu veriler <strong>farkal<\/strong> fonksiyonuna g\u00f6nderilerek iki tarih aras\u0131ndaki g\u00fcn say\u0131s\u0131n\u0131 buluyoruz. <\/p>\n\n\n\n<p>A\u015fa\u011f\u0131daki kodda yap\u0131lan i\u015flemler istenirse datetime k\u00fct\u00fcphanesi ile \u00e7ok daha basit ve k\u0131sa s\u00fcrede yap\u0131labilmektedir. \u0130sterseniz datetime k\u00fct\u00fcphanesini de kullanabilirsiniz.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aylar = &#91;31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31]\ndef artikyil(d):\n    yil = d.y\n    if (d.m &lt;= 2):\n        yil -= 1\n    ans = int(yil \/ 4)\n    ans -= int(yil \/ 100)\n    ans += int(yil \/ 400)\n    return ans\ndef farkal(dt1, dt2):\n    n1 = dt1.y * 365 + dt1.d\n    for i in range(0, dt1.m - 1):\n        n1 += aylar&#91;i]\n    n1 += artikyil(dt1)\n    n2 = dt2.y * 365 + dt2.d\n    for i in range(0, dt2.m - 1):\n        n2 += aylar&#91;i]\n    n2 += artikyil(dt2)\n    return (n2 - n1)\nclass tarih:                         \n   def __init__(self, d, m, y, s): \n     self.d = d                           \n     self.m = m\n     self.y = y\n     self.s = s\ntarih_1 = tarih(1, 9, 2014, 23)\ntarih_2 = tarih(3, 9, 2020, 22)\nfarkgun=farkal(tarih_1,tarih_2)\nif(tarih_1.s&gt;tarih_2.s):\n    farkgun=farkgun-1\n    tarih_2.s=tarih_2.s+24\nprint(\"Iki tarih arasindaki fark: \",farkgun,\"gun.\")\nprint(\"Iki tarih arasindaki saat: \",(farkgun*24)+(tarih_2.s-tarih_1.s),\"saat.\")<\/code><\/pre>\n\n\n\n<p>\u0130lgili \u00e7al\u0131\u015fmaya <em><a href=\"https:\/\/github.com\/YeD-Mi\/Python-Tarih-Cikarma\">github<\/a><\/em> \u00fczerinden de ula\u015fabilirsiniz.<\/p>","protected":false},"excerpt":{"rendered":"<p>Python ile belirtilen iki tarih aras\u0131ndaki g\u00fcn fark\u0131n\u0131 hesaplad\u0131k. Yine belirtilen saat ile de aradaki saat fark\u0131n\u0131 bulduk. Bu fark bulma i\u015fleminde art\u0131k y\u0131lda dikkate al\u0131nm\u0131\u015ft\u0131r.<\/p>","protected":false},"author":1,"featured_media":454,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,11],"tags":[53,52],"class_list":["post-447","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-yazilim","tag-iki-tarih-arasi-gun-hesaplama-python","tag-python-datetime-turkish"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre<\/title>\n<meta name=\"description\" content=\"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mryed.com\/en\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre\" \/>\n<meta property=\"og:description\" content=\"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mryed.com\/en\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\" \/>\n<meta property=\"og:site_name\" content=\"Yunus Emre\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-26T08:27:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-26T08:27:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mr.YED\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mr.YED\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\"},\"author\":{\"name\":\"Mr.YED\",\"@id\":\"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1\"},\"headline\":\"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama\",\"datePublished\":\"2022-01-26T08:27:46+00:00\",\"dateModified\":\"2022-01-26T08:27:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\"},\"wordCount\":128,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1\"},\"image\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png\",\"keywords\":[\"\u0130ki tarih Aras\u0131 g\u00fcn hesaplama Python\",\"Python datetime turkish\"],\"articleSection\":[\"Python\",\"Yaz\u0131l\u0131m\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\",\"url\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\",\"name\":\"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre\",\"isPartOf\":{\"@id\":\"https:\/\/mryed.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png\",\"datePublished\":\"2022-01-26T08:27:46+00:00\",\"dateModified\":\"2022-01-26T08:27:48+00:00\",\"description\":\"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.\",\"breadcrumb\":{\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage\",\"url\":\"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png\",\"contentUrl\":\"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png\",\"width\":1920,\"height\":900,\"caption\":\"python-datetime-kutuphanesi\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/mryed.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mryed.com\/#website\",\"url\":\"https:\/\/mryed.com\/\",\"name\":\"Yunus Emre\",\"description\":\"Software Engineer\",\"publisher\":{\"@id\":\"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mryed.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1\",\"name\":\"Mr.YED\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png\",\"url\":\"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png\",\"contentUrl\":\"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png\",\"width\":360,\"height\":360,\"caption\":\"Mr.YED\"},\"logo\":{\"@id\":\"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png\"},\"description\":\"Mobil, web ve Microsoft tabanl\u0131 uygulamalar geli\u015ftiren bir yaz\u0131l\u0131m m\u00fchendisiyim. Kariyerim boyunca farkl\u0131 sekt\u00f6rlerde edindi\u011fim deneyimlerle \u00f6zellikle Power Platform, Power Apps, Power Automate ve kurumsal s\u00fcre\u00e7 otomasyonu konular\u0131nda uzmanla\u015ft\u0131m. Bu blogda yaz\u0131l\u0131m geli\u015ftirme, otomasyon ve Microsoft teknolojileri \u00fczerine edindi\u011fim tecr\u00fcbeleri payla\u015f\u0131yorum.\",\"sameAs\":[\"http:\/\/mryed.com\",\"https:\/\/www.linkedin.com\/in\/yunus-emre-demirel\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre","description":"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mryed.com\/en\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/","og_locale":"en_US","og_type":"article","og_title":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre","og_description":"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.","og_url":"https:\/\/mryed.com\/en\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/","og_site_name":"Yunus Emre","article_published_time":"2022-01-26T08:27:46+00:00","article_modified_time":"2022-01-26T08:27:48+00:00","og_image":[{"width":1920,"height":900,"url":"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png","type":"image\/png"}],"author":"Mr.YED","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mr.YED","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#article","isPartOf":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/"},"author":{"name":"Mr.YED","@id":"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1"},"headline":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama","datePublished":"2022-01-26T08:27:46+00:00","dateModified":"2022-01-26T08:27:48+00:00","mainEntityOfPage":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/"},"wordCount":128,"commentCount":0,"publisher":{"@id":"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1"},"image":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage"},"thumbnailUrl":"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png","keywords":["\u0130ki tarih Aras\u0131 g\u00fcn hesaplama Python","Python datetime turkish"],"articleSection":["Python","Yaz\u0131l\u0131m"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/","url":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/","name":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama - Yunus Emre","isPartOf":{"@id":"https:\/\/mryed.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage"},"image":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage"},"thumbnailUrl":"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png","datePublished":"2022-01-26T08:27:46+00:00","dateModified":"2022-01-26T08:27:48+00:00","description":"Datetime k\u00fct\u00fcphanesi kullanmadan Python 2 tarih aras\u0131ndaki saat fark\u0131 hesaplama uygulamas\u0131. Fonksiyon kullan\u0131larak yap\u0131lm\u0131\u015ft\u0131r.","breadcrumb":{"@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#primaryimage","url":"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png","contentUrl":"https:\/\/mryed.com\/wp-content\/uploads\/2022\/01\/python-gun-hesaplama.png","width":1920,"height":900,"caption":"python-datetime-kutuphanesi"},{"@type":"BreadcrumbList","@id":"https:\/\/mryed.com\/yazilim\/kodlama\/python\/tarih-farki-hesaplama\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/mryed.com\/"},{"@type":"ListItem","position":2,"name":"Python 2 Tarih Aras\u0131ndaki Fark\u0131 Hesaplama"}]},{"@type":"WebSite","@id":"https:\/\/mryed.com\/#website","url":"https:\/\/mryed.com\/","name":"Yunus Emre","description":"Software Engineer","publisher":{"@id":"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mryed.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/mryed.com\/#\/schema\/person\/4bb44b3409df8d51fc489343880ffea1","name":"Mr.YED","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png","url":"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png","contentUrl":"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png","width":360,"height":360,"caption":"Mr.YED"},"logo":{"@id":"https:\/\/mryed.com\/wp-content\/uploads\/2021\/03\/yunus-emre-demirel.png"},"description":"I am a software engineer who develops mobile, web, and Microsoft-based applications. Throughout my career, I have gained experience in various industries and specialized in Power Platform, Power Apps, Power Automate, and enterprise process automation. In this blog, I share my experiences in software development, automation, and Microsoft technologies.","sameAs":["http:\/\/mryed.com","https:\/\/www.linkedin.com\/in\/yunus-emre-demirel\/"]}]}},"_links":{"self":[{"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/posts\/447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/comments?post=447"}],"version-history":[{"count":4,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/posts\/447\/revisions"}],"predecessor-version":[{"id":455,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/posts\/447\/revisions\/455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/media\/454"}],"wp:attachment":[{"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/media?parent=447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/categories?post=447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mryed.com\/en\/wp-json\/wp\/v2\/tags?post=447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}