Solved

SQL database Day and time

Posted on 2011-02-13
3
261 Views
Last Modified: 2012-05-11
Hi

I am new to SQL and am adding a table that holds calendar details.
Should I use a separate column for Date and another for Time  (if so what data type)
or should I use one column for date and time (if so what data type)
Thanks
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 34882514
Questions are:

What kind of a calendar do you have?
What do you want to store? date and time and timezone?
What queries of the data do you think of?

For example if you have a event calender and you want to enable users to search for events at a certain time range, say in the evening from 2000 to 2200, independant of the date, then you better store the time portion seperate. You can since sql 2008, as it offers the time data type.

If you need to compute differences from datetime 1 to datetime 2, then it's better to store date and time in a datetime field, depending on the precision you need smalldatetime or datetime.

Also, if the calender is storing times for different time zones, you can make use of the datetimeoffset data type.

Here's more in detail of the different date and time data types of sql server 2008:
http://www.mssqltips.com/tip.asp?tip=1616

Bye, Olaf.


0
 

Author Comment

by:murbro
ID: 34882549
I am storing school calendar events.
An example of one entry would be:

Nov 5
3:30 pm
U15 tennis finals
0
 

Author Closing Comment

by:murbro
ID: 34882757
Thanks that link helped a lot
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question