Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Only save date in datetime filed

Author  Topic 

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-14 : 12:31:49
Hi

I'm having two datetime field in my table. One is Call date and another one is Calltime because of some calculations. So I want to save calldate like 4/14/2008 and calltime like 9:30 PM.

Kindly help me.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-14 : 12:36:17
Have a look at CONVERT() function in BOL
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-04-14 : 12:50:28
Until sql server comes out with independent date and time datatypes I suggest you store the single datetime value. We can help with your calculation code for a single datetime value if you like. Just post the requirment.

If you do want to seperate the values into 2 columns I would either store the all the dates with 00:00:00.000 time and all the times with 1900-01-01 date. Or use an int for each where the date is the number of days past 1900-01-01 and the time is the number of milliseconds past midnight.

One thing you should not do is store the time in varchar like '9:30 PM' because that takes away your ability to perform calculations on it.


Be One with the Optimizer
TG
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-14 : 13:20:07
there's really no need to store this in 2 different columns.
store them in one datetime column since this is one piece of information and not 2.

date and time are separated in Katmai. i wonder what kind of date and time molesting will we see with those two...

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -