Hello i have an array of dates and want to input a week
ex week #14 and get all the dates written out in that week.

Anyone know a good way to convert weeks to dates or how i should solve this? thx for answer.

Hello i have an array of dates and want to input a week
ex week #14 and get all the dates written out in that week.

Anyone know a good way to convert weeks to dates or how i should solve this? thx for answer.

1. What's your "date"? You (and me) know that no such standard type in C++...
2. OK, you have an array of dates. And what did you want to do with these lots of dates?
3. a week ex week #14... What is it?...

He wants to input a calendar week number and get all dates within this week.
Calculating week #1 of a year is not trivial, as there are different algorithms how to determine the first week of a year from country to country.

He wants to input a calendar week number and get all dates within this week.
Calculating week #1 of a year is not trivial, as there are different algorithms how to determine the first week of a year from country to country.

It's a trivial task in C and C++: fill struct tm tm_year, tm_month and tm_day data fields (clear other fieelds), get its time value by mktime then get a new complete struct tm by localtime. The tm_wday member gets days since Sunday value.

For this locale number of week rules you can determinate number of week for every date: get day of week for January 1 then use difftime and old good modulo operator diif % 7 with some trivial calculations ;)...

However "array of dates" is not a complete specification.

The TO wrote "calendar week", and calendar week #1 of a year may start i.e. on January 4th (January 3rd is in week #52 of the year before).

sorry i havent resopned been too busy an sorry if it was abit unclear what i wanted i'll try like this im writing a program that compares values that are connected to dates both in arrays and i want the user of the program to be able to choose from 3 different types of comparement
#1 years

this one was easy i just made the program ask for a year to compare and made an if statement

``````cin >>date
if ((array[0]>date*10000) && (array[0]<(date+1)*10000))``````

for example
date=1999
array[0]=19990506
then its bigger then 19990000 and smaller then 20000000
And then i compare this value with the others coz it passed the date req

so i solved mounths like this too but i dontk now how to transform the date (20030903) too weeks to check if i would compare that value or not

so i put in the week (5) and in my little for loop it picks out every date in my array thats in that week.