# Write a program to read today’s date (only date part) from user. Then display how many days are left in the current month.

In this post, we will see how to read only date part from today’s date and also check how many days left in current month. In order to do this, we need to extract date,month from user entered date and then we will find out total days of that particular month. When we get total days of particular month,we can easily calculate number of days left in that month by simply subtracting days from total days of the current month.

Python provides datetime module to perform different types of operation on date and time. I will use datetime module to code this programs. Lets see how to include datetime module in program and how to use different methods and function of datetime module to extract month and days from date successfully.

## How to include datetime module in python code

To include datetime module in python program, we need to write import keyword alongwith modulename as shown below

import datetime

Now,we can access all methods and functions of datetime module.

Then we ask user to enter any date by using input() . I will use strptime() method of datetime module to format date in desired format. It will creates date object.

```current_date = input("Enter current date (yyyy-mm-dd) in given format :")

```

We will extract month and date from user entered date which is in yyyy/mm/dd format. Month will be stored in current_month and date will be stored in current_date variable

```my_date = datetime.strptime(current_date, "%Y-%m-%d")
current_month = my_date.month
current_date = my_date.day

```

Then we will find the total days of current_month. If Current_month is February then total_days will be 28 .If current_month is march then total _days will be 31. In this way, we can find out total days of given month. To implement this logic, we will use nested if-else loop . See following code

```if current_month==2:
total_days=28
elif current_month in(1,3,4,7,8,10,12):
total_days=31
else:
total_days=30
print("Total remaining days in the current month are : ",total_days-current_date)

```
```
```

## Output

```Enter current date (yyyy-mm-dd) in given format :2022-02-22
Total remaining days in the current month are : 6

Enter current date (yyyy-mm-dd) in given format :2022-03-10
Total remaining days in the current month are : 21
```

<