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
 General SQL Server Forums
 New to SQL Server Programming
 Time only in SS 2005?

Author  Topic 

absjoe
Starting Member

2 Posts

Posted - 2009-11-21 : 06:09:04

Since SS 2005 does not have a Time only data type, what do I do if all I need is the time?

I want to have two fields: TimeFrom and TimeTo

Do I use smalldatetime for both of them? But how?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-21 : 08:31:26
you can use either datetime or smalldatetime depending on your requirement and set date as 1900-01-01

to get the current time only use

select getdate() - dateadd(day, datediff(day, 0, getdate()), 0)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-23 : 01:33:16
quote:
Originally posted by absjoe


Since SS 2005 does not have a Time only data type, what do I do if all I need is the time?

I want to have two fields: TimeFrom and TimeTo

Do I use smalldatetime for both of them? But how?



Doesn't it support format function?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2009-11-23 : 02:23:06
SELECT CONVERT(VARCHAR(20), GETDATE(), 108)
Go to Top of Page
   

- Advertisement -