I want to select sql:
SELECT "year-month" from table group by "year-month" AND order by date
, where
year-month - format for date "1978-01","1923-12".
select to_char of couse work, but not "right" order:
to_char(timestamp_column, 'YYYY-MM')
Except the above formula, you can also apply this formula: =TEXT(A2, "mmm") & "-" & TEXT(A2, "yyyy"). 2. In above formulas, A2 indicates the date cell that you want to use, and the separator “-” is used to separate the month and year, you can change it to any other delimiters you need.
You'll need to use the to_char function to extract the year-month from timestamp. Show activity on this post. select extract(year from timestmp) || '-' || extract(month from timestmp) from texmp1; Hope this helps.
The PostgreSQL to_char function converts a number or date to a string.
to_char(timestamp, 'YYYY-MM')
You say that the order is not "right", but I cannot see why it is wrong (at least until year 10000 comes around).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With