Solved

SQL database Day and time

Posted on 2011-02-13
3
268 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Murray Brown
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:Murray Brown
ID: 34882757
Thanks that link helped a lot
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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 …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

687 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