Given number of days, convert it in terms of Years, Week and Days.

**Examples :**

Input : 30 Output : years = 0 week = 4 days = 2 Input : 20 Output : years = 0 week = 2 days = 6

**Approach :**

- Number of years will be the quotient when number of days will be divided by 365 i.e days / 365 = years.
- Number of weeks will be the result of (Number_of_days % 365) / 7.
- Number of days will be the result of (Number_of_days % 365) % 7.

Below is the program implementing above approach:

## C

`// C program to convert given ` `// number of days in terms of ` `// Years, Weeks and Days ` `#include <stdio.h> ` `#define DAYS_IN_WEEK 7 ` ` ` `// Function to find year, ` `// week, days ` `void` `find(` `int` `number_of_days) ` `{ ` ` ` `int` `year, week, days; ` ` ` ` ` `// Assume that years is ` ` ` `// of 365 days ` ` ` `year = number_of_days / 365; ` ` ` `week = (number_of_days % 365) / ` ` ` `DAYS_IN_WEEK; ` ` ` `days = (number_of_days % 365) % ` ` ` `DAYS_IN_WEEK; ` ` ` `printf` `(` `"years = %d"` `,year); ` ` ` `printf` `(` `"\nweeks = %d"` `, week); ` ` ` `printf` `(` `"\ndays = %d "` `,days); ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `number_of_days = 200; ` ` ` `find(number_of_days); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to convert given ` `// number of days in terms of ` `// Years, Weeks and Days ` `class` `GFG ` `{ ` ` ` `static` `final` `int` `DAYS_IN_WEEK = ` `7` `; ` ` ` ` ` `// Function to find year, week, days ` ` ` `static` `void` `find(` `int` `number_of_days) ` ` ` `{ ` ` ` `int` `year, week, days; ` ` ` ` ` `// Assume that years ` ` ` `// is of 365 days ` ` ` `year = number_of_days / ` `365` `; ` ` ` `week = (number_of_days % ` `365` `) / ` ` ` `DAYS_IN_WEEK; ` ` ` `days = (number_of_days % ` `365` `) % ` ` ` `DAYS_IN_WEEK; ` ` ` ` ` `System.out.println(` `"years = "` `+ year); ` ` ` `System.out.println(` `"weeks = "` `+ week); ` ` ` `System.out.println(` `"days = "` `+ days); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `number_of_days = ` `200` `; ` ` ` `find(number_of_days); ` ` ` `} ` `} ` ` ` `// This code is contributed by Azkia Anam. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 code to convert given ` `# number of days in terms of ` `# Years, Weeks and Days ` ` ` `DAYS_IN_WEEK ` `=` `7` ` ` `# Function to find ` `# year, week, days ` `def` `find( number_of_days ): ` ` ` ` ` `# Assume that years is ` ` ` `# of 365 days ` ` ` `year ` `=` `int` `(number_of_days ` `/` `365` `) ` ` ` `week ` `=` `int` `((number_of_days ` `%` `365` `) ` `/` ` ` `DAYS_IN_WEEK) ` ` ` `days ` `=` `(number_of_days ` `%` `365` `) ` `%` `DAYS_IN_WEEK ` ` ` ` ` `print` `(` `"years = "` `,year, ` ` ` `"\nweeks = "` `,week, ` ` ` `"\ndays = "` `,days) ` ` ` `# Driver Code ` `number_of_days ` `=` `200` `find(number_of_days) ` ` ` `# This code contributed ` `#by "Sharad_Bhardwaj" ` |

*chevron_right*

*filter_none*

## C#

`// C# program to convert given ` `// number of days in terms of ` `// Years, Weeks and Days ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `static` `int` `DAYS_IN_WEEK = 7; ` ` ` ` ` `// Function to find ` ` ` `// year, week, days ` ` ` `static` `void` `find(` `int` `number_of_days) ` ` ` `{ ` ` ` ` ` `int` `year, week, days; ` ` ` ` ` `// Assume that years ` ` ` `// is of 365 days ` ` ` `year = number_of_days / 365; ` ` ` `week = (number_of_days % 365) / ` ` ` `DAYS_IN_WEEK; ` ` ` `days = (number_of_days % 365) % ` ` ` `DAYS_IN_WEEK; ` ` ` ` ` `Console.WriteLine(` `"years = "` `+ ` ` ` `year); ` ` ` `Console.WriteLine(` `"weeks = "` `+ ` ` ` `week); ` ` ` `Console.WriteLine(` `"days = "` `+ ` ` ` `days); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `number_of_days = 200; ` ` ` ` ` `find(number_of_days); ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to convert ` `// given number of days in ` `// terms of Years, Weeks and Days ` `$DAYS_IN_WEEK` `= 7; ` ` ` `// Function to find ` `// year, week, days ` `function` `find(` `$number_of_days` `) ` `{ ` ` ` `global` `$DAYS_IN_WEEK` `; ` ` ` `$year` `; ` `$week` `; ` `$days` `; ` ` ` ` ` `// Assume that years ` ` ` `// is of 365 days ` ` ` `$year` `= (int)(` `$number_of_days` `/ 365); ` ` ` `$week` `= (int)((` `$number_of_days` `% 365) / ` ` ` `$DAYS_IN_WEEK` `); ` ` ` `$days` `= (` `$number_of_days` `% 365) % ` ` ` `$DAYS_IN_WEEK` `; ` ` ` `echo` `(` `"years = "` `. ` `$year` `. ` ` ` `"\nweeks = "` `. ` `$week` `. ` ` ` `"\ndays = "` `. ` `$days` `); ` `} ` ` ` `// Driver Code ` `$number_of_days` `= 200; ` `find(` `$number_of_days` `); ` ` ` `// This code is contributed by Ajit. ` `?> ` |

*chevron_right*

*filter_none*

**Output :**

years = 0 weeks = 28 days = 4

## Recommended Posts:

- Sum of P terms of an AP if Mth and Nth terms are given
- Find n terms of Fibonacci type series with given first two terms
- Python program to find number of days between two given dates
- Date after adding given number of days to the given date
- C program to print number of days in a month
- Find number of days between two given dates
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Find Pth term of a GP if Mth and Nth terms are given
- Program to find the sum of the series 23+ 45+ 75+..... upto N terms
- Program to print the series 2, 1, 4, 3, 6, 5, .... up to N terms
- Program to print the series 1, 9, 17, 33, 49, 73, 97... till N terms
- Find the day of the week after K days from the given day
- Finding number of days between two dates using StringStream
- PHP | Number of week days between two dates
- Converting seconds into days, hours, minutes and seconds
- Sum of the series 0.6, 0.06, 0.006, 0.0006, ...to n terms
- Sum of the series 0.7, 0.77, 0.777, ... upto n terms
- Sum of series 2/3 - 4/5 + 6/7 - 8/9 + ------- upto n terms
- Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + - - - - - - upto n terms.
- Sum of the series 5+55+555+.. up to n terms

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.