If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Create a table with a field with only Time datatype

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-06, 03:03
Mahfuz Mahfuz is offline
Registered User
 
Join Date: Nov 2003
Location: Dhaka,Bangladesh
Posts: 86
Create a table with a field with only Time datatype

Hello experts,
I want to create a table to store only time in a fileld. There is "DateTime" for my purpose but i dont want to save the Date part only the time part as "12:30:44 AM". I know i can select only time part from Datetime field but i want to save only time.Can anybody help me how can i create that kinda table ?
__________________
hello
Reply With Quote
  #2 (permalink)  
Old 07-13-06, 03:52
rudra rudra is offline
L O S T in Reality
 
Join Date: Nov 2005
Location: San Francisco, CA
Posts: 505
Quote:
Originally Posted by Mahfuz
Hello experts,
I want to create a table to store only time in a fileld. There is "DateTime" for my purpose but i dont want to save the Date part only the time part as "12:30:44 AM". I know i can select only time part from Datetime field but i want to save only time.Can anybody help me how can i create that kinda table ?
See this enigma's post link
Its a good one ...
__________________
Success is the ability to go from one failure to another with no loss of enthusiasm.
- Sir Winston Churchill
Joydeep
Reply With Quote
  #3 (permalink)  
Old 07-14-06, 05:03
upalsen upalsen is offline
Registered User
 
Join Date: Feb 2003
Location: India
Posts: 216
i dont understand why you are not thinking in terms of a datetime/smalldatetime field by ignoring the date part and whats wrong in it. however, if you are rigid you can store it either as char field or as numeric field (float/decimal). remember you do not actually save anything by doing so.

storing as char field is straight forward. if you want to store as number (remember that each date+time has a numeric representation) can take hints from the following queries

----1 minute as number
select cast(cast('20060101 11:01 AM' as smalldatetime) as float)- cast(cast('20060101 11:00 AM' as smalldatetime) as float)
---it returns approx 0.0006944

----use that to get a date time 20060101 11:00 AM back
select cast( cast(cast('20060101' as smalldatetime) as float) + (0.0006944*60*11) as smalldatetime)

quite unnecessary....;-)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On