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
Solved

SQL database Day and time

Posted on 2011-02-13
3
263 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

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 …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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