Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the datatype of Months(only months) in postgres?

Tags:

postgresql

I need to create a table with a column named as "months" in postgresql."Month" column should have January, February,etc not as 1, 2,3, etc. And I need to retrieve data ordered by months. what is the datatype I should used and how can I retrieve data ordered by month?

like image 923
Pirinthan Avatar asked Jan 08 '23 21:01

Pirinthan


1 Answers

If you only need to save months, and not entire dates, I'd create an enum:

CREATE TYPE month_enum AS ENUM
('January', 
 'February',
 'March', 
 'April',
 'May',
 'June',
 'July',
 'August',
 'September',
 'October',
 'November',
 'December'
);
like image 53
Mureinik Avatar answered Jan 16 '23 05:01

Mureinik