query-066db862e93e9b8b946c559072e458d7
using https://cs.wikipedia.org/wiki/Algoritmus_pro_v%C3%BDpo%C4%8Det_dne_v_t%C3%BDdnu#Zeller%C5%AFv_algoritmus SELECT ?disaster ?disasterLabel ?start_time WHERE { ?disaster wdt:P31/wdt:P279* wd:Q3839081 ; wdt:P580 ?start_time . BIND( DAY( ?start_time ) AS ?q ) . FILTER( ?q = 13 ) . BIND( MONTH( ?start_time ) + IF( MONTH( ?start_time ) < 3, 12, 0 ) AS ?m ) . BIND( YEAR( ?start_time ) - IF( MONTH( ?start_time ) < 3, 1, 0 ) AS ?_year ) . BIND( ?_year - FLOOR( ?_year / 100 ) * 100 AS ?K ) . # modulo BIND( FLOOR( YEAR( ?start_time ) / 100 ) AS ?J ) . BIND( ?q + FLOOR( 13 * ( ?m + 1 ) / 5 ) + ?K + FLOOR( ?K / 4 ) + FLOOR( ?J / 4 ) - 2 * ?J AS ?_h ) . FILTER( ?_h - FLOOR( ?_h / 7 ) * 7 = 6 ) . # modulo, 0 is Saturday SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . }
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# using https://cs.wikipedia.org/wiki/Algoritmus_pro_v%C3%BDpo%C4%8Det_dne_v_t%C3%BDdnu#Zeller%C5%AFv_algoritmus
SELECT ?disaster ?disasterLabel ?start_time WHERE {
?disaster wdt:P31/wdt:P279* wd:Q3839081 ;
wdt:P580 ?start_time .
BIND( DAY( ?start_time ) AS ?q ) .
FILTER( ?q = 13 ) .
BIND( MONTH( ?start_time ) + IF( MONTH( ?start_time ) < 3, 12, 0 ) AS ?m ) .
BIND( YEAR( ?start_time ) - IF( MONTH( ?start_time ) < 3, 1, 0 ) AS ?_year ) .
BIND( ?_year - FLOOR( ?_year / 100 ) * 100 AS ?K ) . # modulo
BIND( FLOOR( YEAR( ?start_time ) / 100 ) AS ?J ) .
BIND( ?q + FLOOR( 13 * ( ?m + 1 ) / 5 ) + ?K + FLOOR( ?K / 4 ) + FLOOR( ?J / 4 ) - 2 * ?J AS ?_h ) .
FILTER( ?_h - FLOOR( ?_h / 7 ) * 7 = 6 ) . # modulo, 0 is Saturday
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } .
}