von benediktlangmantl » Mo, 22.01.2018 23:57
Hallo, ich habe folgende Abfrage in Base gemacht
Code: Alles auswählen
SELECT "M_ID", "Name", "Vorname", "Geb-Datum", DATEDIFF( 'yy', "Geb-Datum", CURRENT_DATE ) - CASEWHEN( DAYOFYEAR( "Geb-Datum" ) > DAYOFYEAR( CURRENT_DATE ), 1, 0 ) AS "Alter", "Anrede", "Straße", "PLZ", "Ort", "Land", "Telefon1", "Telefon2", "Telefax", "Telefax", "E-Mail", "Eintritt", "Austritt", DATEDIFF( 'yy', "Eintritt", CURDATE( ) ) AS "Mitgliedsjahre", "Bemerkung", "Foto", "Status" FROM "tbl_Mitglieder"
ich bekomme es hin, die Mitgliedsjahre ausgehend vom Eintrittsdatum zu berechnen. wie muss ich die SQL Ändern, wenn im Feld Austritt etwas steht. Dann soll von Eintrittsdatum bis Austrittsdatum berechnet werden und nicht wie bisher bis heute
Danke schon mal im Voraus aus Berlin
Hallo, ich habe folgende Abfrage in Base gemacht [code]SELECT "M_ID", "Name", "Vorname", "Geb-Datum", DATEDIFF( 'yy', "Geb-Datum", CURRENT_DATE ) - CASEWHEN( DAYOFYEAR( "Geb-Datum" ) > DAYOFYEAR( CURRENT_DATE ), 1, 0 ) AS "Alter", "Anrede", "Straße", "PLZ", "Ort", "Land", "Telefon1", "Telefon2", "Telefax", "Telefax", "E-Mail", "Eintritt", "Austritt", DATEDIFF( 'yy', "Eintritt", CURDATE( ) ) AS "Mitgliedsjahre", "Bemerkung", "Foto", "Status" FROM "tbl_Mitglieder"[/code]
ich bekomme es hin, die Mitgliedsjahre ausgehend vom Eintrittsdatum zu berechnen. wie muss ich die SQL Ändern, wenn im Feld Austritt etwas steht. Dann soll von Eintrittsdatum bis Austrittsdatum berechnet werden und nicht wie bisher bis heute
Danke schon mal im Voraus aus Berlin