Solved

SQL database Day and time

Posted on 2011-02-13
3
258 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks that link helped a lot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now