1. 程式人生 > 資料庫 >PostgreSQL將日期轉為當前年、月、日的函式date_trunc

PostgreSQL將日期轉為當前年、月、日的函式date_trunc

  PostgreSQL將日期轉為年、月、日的函式date_trunc:

  當前年:  select  date_trunc('year',now())

  當前月:  select  date_trunc('month',now())

  當前日:  select  date_trunc('day',now())

  當前時:  select  date_trunc('hour',now())

  當前分:  select  date_trunc('minute',now())

  當前秒:  select  date_trunc('second',now())