Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:04:04+00:00 2026-06-15T15:04:04+00:00

What is the best PostgreSQL data type for year data, e.g., 2006 or 1847.

  • 0

What is the best PostgreSQL data type for year data, e.g., 2006 or 1847.
TEXT, SMALLINT, DATE? Ideally, I’d like to be able to query that column with a second year-month-day column (in DATE format).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:04:04+00:00Added an answer on June 15, 2026 at 3:04 pm

    A year is an integer and even supports integer arithmetic in a meaningful way so text makes no sense. You don’t have a month or day so date is right out the window. The fine manual has this to say about smallint:

    The smallint type is generally only used if disk space is at a premium.

    That leaves integer as a natural choice. If you’re planning to combine this value with dates and timestamps, then interval might make sense as the date and time functions and operators have a good understanding of intervals.

    So it depends on what you’re planning on doing with this “year” and what it really is. Sounds like a simple integer is appropriate but you might have to muck around a bit to combine it with your “second year-month-day column” (a date column presumably) depending on how they need to work together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the best way to represent a sparse data matrix in PostgreSQL? The two
I need to store data that looks like this: <root> <child-one> value 1 value
A query (see below) that extracts climate data from weather stations within a given
Now I'm developing application that uses hibernate + postgresql to persist data. We need
In postgresql, I need to insert data to, say table B from sql query
What would be the best way to insert XML data (that I get from
I'm looking for the best way to handle deleting linked data across three PostgreSQL
Best way to match 2 pages for Google analytics. Pages to Query: 1.) this_google.html
The application that I have in the works uses GPS data to mark files
If you wanted to manipulate the data in a table in a postgresql database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.