Translations:Faq/Base/121/9/it

From The Document Foundation Wiki
Jump to: navigation, search
SELECT "DateNaissance", "Nom", YEAR(NOW())-YEAR("DateNaissance")-
CASE WHEN (MONTH( NOW() ) < MONTH("DateNaissance") OR ( MONTH( NOW() ) = MONTH("DateNaissance") AND 
DAY( NOW() ) < DAY ("DateNaissance"))) THEN 1 ELSE 0 END AS "ans", 
MONTH(NOW())-MONTH("DateNaissance") +
CASE WHEN MONTH(now()) <= MONTH("DateNaissance") AND DAY(NOW()) < DAY("DateNaissance")
THEN 11 ELSE
CASE 
WHEN MONTH(NOW()) < MONTH("DateNaissance") AND DAY(NOW()) >= DAY("DateNaissance")
THEN 12 ELSE
CASE WHEN MONTH(NOW()) > MONTH("DateNaissance") AND DAY(NOW()) < DAY("DateNaissance")
THEN -1 ELSE 0
END
END
END AS "mois", 
DATEDIFF('DAY', CAST(YEAR(NOW()) || '-' || RIGHT( 0 || MONTH(NOW())  - casewhen DAY(NOW()) < DAY("DateNaissance")
THEN 1 ELSE 0
END, 2) || '-' || RIGHT( 0 || DAY("DateNaissance"), 2) AS DATE) , NOW() ) AS "jours" FROM "Table1"