Bonjour

voici un algorithme que j'ai devellopé en c# et qui permet de calculer le numéro de la semaine d'une date :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
string date = "01/01/" + kryptonDateTimePicker1.Value.Year; 
DateTime test = new DateTime(); 
test = Convert.ToDateTime(date); 
 
int a = 0; 
 
 
if (test.DayOfWeek.ToString() == "Monday") 
{ a = 1; } 
else if (test.DayOfWeek.ToString() == "Tuesday") 
{ a = 2; } 
else if (test.DayOfWeek.ToString() == "Wednesday") 
{ a = 3; } 
else if (test.DayOfWeek.ToString() == "Thursday") 
{ a = 4; } 
else if (test.DayOfWeek.ToString() == "Friday") 
{ a = 5; } 
else if (test.DayOfWeek.ToString() == "Saturday") 
{ a = 6; } 
else if (test.DayOfWeek.ToString() == "Sunday") 
{ a = 7; } 
 
int x = Convert.ToInt32(kryptonDateTimePicker1.Value.DayOfYear); 
float y = (Convert.ToInt32(kryptonDateTimePicker1.Value.DayOfYear) + a - 1); 
y = y / 7; 
float z; 
int diff = 0; 
if (y <= 1) 
{ 
textBox1.Text = "S" + 1; 
} 
else if (y > 1 ) 
{ 
 
diff = Convert.ToInt32(y); 
z = y - (Convert.ToInt32(y)); 
if (z == 0) 
{ 
 
textBox1.Text = "S" + (int)y; 
} 
else 
{ 
textBox1.Text = "S" + ((int)y +1); 
} 
}
si vous testez et que sa marche pour vous aussi faite circuler.

Salam