简体   繁体   中英

How do I display today's date twice in PostgreSQL

SELECT TO_CHAR(now() :: DATE, 'dd/mm/yyyy');

The above query displays only once.

I want to display the above date twice or more.

If you want to display the same date twice side to side, just query it twice:

SELECT TO_CHAR(now()::DATE, 'dd/mm/yyyy'), TO_CHAR(now()::DATE, 'dd/mm/yyyy');

If you want to display multiple rows, you can use a set-generating function, such as generate_series :

SELECT TO_CHAR(now()::DATE, 'dd/mm/yyyy')
FROM   GENERATE_SERIES(1, 2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM