datum-in-nederlands-vanuit-sql
Gesponsorde koppelingen
PHP script bestanden
( In dit geval: tabel "tabel" met veld "datum" type DATE of DATETIME )
Code (php)
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
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
SELECT
CONCAT(
(CASE DATE_FORMAT(datum, '%w')
WHEN '0' THEN 'zondag'
WHEN '1' THEN 'maandag'
WHEN '2' THEN 'dinsdag'
WHEN '3' THEN 'woensdag'
WHEN '4' THEN 'donderdag'
WHEN '5' THEN 'vrijdag'
WHEN '6' THEN 'zaterdag'
END),
' ',
(DATE_FORMAT(datum, '%d')),
' ',
(CASE DATE_FORMAT(datum, '%c')
WHEN '1' THEN 'januari'
WHEN '2' THEN 'februari'
WHEN '3' THEN 'maart'
WHEN '4' THEN 'april'
WHEN '5' THEN 'mei'
WHEN '6' THEN 'juni'
WHEN '7' THEN 'juli'
WHEN '8' THEN 'augustus'
WHEN '9' THEN 'september'
WHEN '10' THEN 'oktober'
WHEN '11' THEN 'november'
WHEN '12' THEN 'december'
END),
' ',
(DATE_FORMAT(datum, '%Y'))
) AS datum
FROM tabel
CONCAT(
(CASE DATE_FORMAT(datum, '%w')
WHEN '0' THEN 'zondag'
WHEN '1' THEN 'maandag'
WHEN '2' THEN 'dinsdag'
WHEN '3' THEN 'woensdag'
WHEN '4' THEN 'donderdag'
WHEN '5' THEN 'vrijdag'
WHEN '6' THEN 'zaterdag'
END),
' ',
(DATE_FORMAT(datum, '%d')),
' ',
(CASE DATE_FORMAT(datum, '%c')
WHEN '1' THEN 'januari'
WHEN '2' THEN 'februari'
WHEN '3' THEN 'maart'
WHEN '4' THEN 'april'
WHEN '5' THEN 'mei'
WHEN '6' THEN 'juni'
WHEN '7' THEN 'juli'
WHEN '8' THEN 'augustus'
WHEN '9' THEN 'september'
WHEN '10' THEN 'oktober'
WHEN '11' THEN 'november'
WHEN '12' THEN 'december'
END),
' ',
(DATE_FORMAT(datum, '%Y'))
) AS datum
FROM tabel
Of in een testscriptje:
Code (php)
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
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
<?php
$sql = "
SELECT
CONCAT(
(CASE DATE_FORMAT(datum, '%w')
WHEN '0' THEN 'zondag'
WHEN '1' THEN 'maandag'
WHEN '2' THEN 'dinsdag'
WHEN '3' THEN 'woensdag'
WHEN '4' THEN 'donderdag'
WHEN '5' THEN 'vrijdag'
WHEN '6' THEN 'zaterdag'
END),
' ',
(DATE_FORMAT(datum, '%d')),
' ',
(CASE DATE_FORMAT(datum, '%c')
WHEN '1' THEN 'januari'
WHEN '2' THEN 'februari'
WHEN '3' THEN 'maart'
WHEN '4' THEN 'april'
WHEN '5' THEN 'mei'
WHEN '6' THEN 'juni'
WHEN '7' THEN 'juli'
WHEN '8' THEN 'augustus'
WHEN '9' THEN 'september'
WHEN '10' THEN 'oktober'
WHEN '11' THEN 'november'
WHEN '12' THEN 'december'
END),
' ',
(DATE_FORMAT(datum, '%Y'))
) AS datum
FROM tabel";
$query = mysql_query($sql) or trigger_error(mysql_error());
while ($row = mysql_fetch_assoc($query))
{
echo $row['datum'] . '<br>';
}
?>
$sql = "
SELECT
CONCAT(
(CASE DATE_FORMAT(datum, '%w')
WHEN '0' THEN 'zondag'
WHEN '1' THEN 'maandag'
WHEN '2' THEN 'dinsdag'
WHEN '3' THEN 'woensdag'
WHEN '4' THEN 'donderdag'
WHEN '5' THEN 'vrijdag'
WHEN '6' THEN 'zaterdag'
END),
' ',
(DATE_FORMAT(datum, '%d')),
' ',
(CASE DATE_FORMAT(datum, '%c')
WHEN '1' THEN 'januari'
WHEN '2' THEN 'februari'
WHEN '3' THEN 'maart'
WHEN '4' THEN 'april'
WHEN '5' THEN 'mei'
WHEN '6' THEN 'juni'
WHEN '7' THEN 'juli'
WHEN '8' THEN 'augustus'
WHEN '9' THEN 'september'
WHEN '10' THEN 'oktober'
WHEN '11' THEN 'november'
WHEN '12' THEN 'december'
END),
' ',
(DATE_FORMAT(datum, '%Y'))
) AS datum
FROM tabel";
$query = mysql_query($sql) or trigger_error(mysql_error());
while ($row = mysql_fetch_assoc($query))
{
echo $row['datum'] . '<br>';
}
?>