2016-12-16 500 views

回答

2

From the manual

isodow 

    The day of the week as Monday (1) to Sunday (7) 

所以,你只需要從結果中減去1:

psql (9.6.1) 
Type "help" for help. 

postgres=> select extract(isodow from date '2016-12-12') - 1; 
    ?column? 
----------- 
     0 
(1 row) 
postgres=> 
1

使用date_part數功能陶氏()

這裏0 =星期日,1 =星期一,2 =星期二,... 6 =星期六

select extract(dow from date '2016-12-18'); /* sunday */ 

輸出:0

select extract(isodow from date '2016-12-12'); /* Monday */ 

輸出繼電器:1

相關問題