I am creating dashboard, and i have this code which works on Vertica and MS SQL, but not with PosgreSQL.
INT([Order Date]) % 5 1
As result i must have a list:
1
2
3
4
5
How to do that?
CodePudding user response:
in pgsql at the variable end use ::"type"
SELECT to_char(CURRENT_DATE, 'YYYYMMDD')::integer
CodePudding user response:
Use Julian Dates.
For example:
select current_date, extract(julian from current_date) % 5 1
Result:
current_date ?column?
------------ --------
2022-07-07 4
See example at db<>fiddle.