473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How should I store year? as Int or Char(4) ?

dlite922
1,584 Expert 1GB
I've always stored year (like of a vehicles make or a home's built year) as an int.

What datatype do you use to store a 4 or 2 digit year?

I like int for comparison reasons.

Let me know your thoughts. Easy question right? :)





Dan
Mar 7 '10 #1
2 4532
Atli
5,058 Expert 4TB
Hey.

I would most likely use the YEAR type. It's only a single byte and can store years between 1901-2155.
If that doesn't work for some reason, I would go with a SMALLINT. It's twice as big as YEAR, but it can store a much larger range.

I would never use Char(4) though. It's just... wrong :)
Mar 7 '10 #2
dlite922
1,584 Expert 1GB
hmmm YEAR type. I guess that's better than INT since I can use the date functions more flawlessly with them too.

INT is way too large.

Good Advice From Experts as Always!



Dan
Mar 8 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark Anthony | last post by:
ok so first i will give write the question out, my code, the db structure, then what is going wrong. Write a report to return the top store in terms of Sales Dollars for each month sales have...
2
by: ITM | last post by:
Does anyone have an example of an SQL query which returns rows for the year-to-date, but where the "year" commences on August 1st? e.g. select * from mytable where datefield > last august 1st ...
2
by: Bernd Hohmann | last post by:
Dear collegues, small query problem. A table (simplified example)... customer as char(5) inv_date as date amount as double
3
by: jannoergaard | last post by:
Hi I want to write a function that can return a sum for a given date range. The same function should be able to return the sum for the same period year before. Let me give an example: The...
8
by: gacuna | last post by:
i want to insert into a temporal table the result of a store procedure. on sql server the sentence would look like this (already working) INSERT INTO #SHIPINFO exec TESTDTA.S59RSH05 @SCBILLTO,...
0
by: zhenyuandeng | last post by:
Hi, When i call the procedure sp_jysczld_new from the Query Analyzer, it runs slowly. But when i extract the sql scripts from the procedure sp_jysczld_new, it runs quickly. Why? I don't...
11
by: mwebel | last post by:
Hi, i had this problem before (posted here and solved it then) now i have the same problem but more complicated and general... basically i want to store the adress of a istream in a char* among...
1
by: Scott | last post by:
In my web app I'm creating a datatable to show my out in a grid. I have a row that has totals within my datatable. How can I store that total to use in another section of code? my datatable...
3
by: M.-A. Lemburg | last post by:
On 2008-08-07 20:41, Laszlo Nagy wrote: 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. -- Marc-Andre Lemburg eGenix.com
7
by: kkshansid | last post by:
i hav a dropdown list of date 1-31 month january-december year 2001-2009 i want to save it in musql database with dob field datatype date $month=$_POST; $date=$_POST; $year=$_POST;...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.