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 2000 Forums
 Transact-SQL (2000)
 any alternative ?

Author  Topic 

wawansur
Starting Member

44 Posts

Posted - 2009-07-27 : 03:42:04
any alternative to get data of time from system datetime ?

i want me with format "hh:mm:ss"

i use this query, but i think its not simple

SELECT DATEPART(hh, GETDATE()),DATEPART(mi, GETDATE()),DATEPART(ss, GETDATE())



Rgds

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-27 : 03:45:16
Hi

Try this..
SELECT CONVERT(VARCHAR(8),GETDATE(),114)
SELECT CONVERT(VARCHAR(20),GETDATE(),114)

-------------------------
R..
Go to Top of Page

wawansur
Starting Member

44 Posts

Posted - 2009-07-27 : 04:22:02
quote:
Originally posted by rajdaksha

Hi

Try this..
SELECT CONVERT(VARCHAR(8),GETDATE(),114)
SELECT CONVERT(VARCHAR(20),GETDATE(),114)

-------------------------
R..




but we got the varchar data type, not datetime type.
how to convert this?

Rgds
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-27 : 04:54:43
quote:
Originally posted by wawansur

any alternative to get data of time from system datetime ?

i want me with format "hh:mm:ss"

i use this query, but i think its not simple

SELECT DATEPART(hh, GETDATE()),DATEPART(mi, GETDATE()),DATEPART(ss, GETDATE())



Rgds


Where do you want to show data?

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-27 : 05:06:38
[code]
select getdate() - dateadd(day, datediff(day, 0, getdate()), 0)
[/code]


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

Go to Top of Page
   

- Advertisement -