{"id":16204,"date":"2021-08-12T09:36:46","date_gmt":"2021-08-12T04:06:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=16204"},"modified":"2021-11-22T18:38:27","modified_gmt":"2021-11-22T13:08:27","slug":"python-program-to-find-the-number-of-weeks-between-two-dates","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-number-of-weeks-between-two-dates\/","title":{"rendered":"Python Program to Find the Number of Weeks between two Dates"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Print all Disarium Numbers within Given range<\/a>
\nDateTime:<\/strong><\/p>\n

It is a date and time combination with the attributes year, month, day, hour, minute, second, microsecond, and tzinfo.<\/p>\n

Date and time are not data types in Python, but a module called DateTime can be imported to work with both the date and the time. There is no need to install the Datetime module externally because it is built into Python.<\/p>\n

The Datetime module includes classes for working with dates and times. These classes offer a variety of functions for working with dates, times, and time intervals. In Python, date and DateTime are objects, so when you manipulate them, you are actually manipulating objects rather than strings or timestamps.<\/p>\n

Given two dates, and the task is to find the number of weeks between the given two dates.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given First date =2003-11- 10  (YY-MM-DD)\r\nGiven second date=2007-4- 12<\/pre>\n

Output:<\/strong><\/p>\n

The number of weeks between two given dates =  178<\/pre>\n

Example 2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given First date =1998-5-16 (YY-MM-DD)\r\nGiven second date=2001-7- 9<\/pre>\n

Output:<\/strong><\/p>\n

The number of weeks between two given dates =  164<\/pre>\n

Program to Find the Number of Weeks between two Dates<\/h2>\n

Below are the ways to Find the Number of Weeks between two Dates.<\/p>\n