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
 Simple format question (hh:mm:ss)

Author  Topic 

shifis
Posting Yak Master

157 Posts

Posted - 2006-03-08 : 15:27:37
How can I get the next information hh:mm:ss in a char var of the getdate() function?

Tahsin
Starting Member

34 Posts

Posted - 2006-03-08 : 15:43:55
What exactly do you mean by the "next information"?
Go to Top of Page

Tahsin
Starting Member

34 Posts

Posted - 2006-03-08 : 15:49:55
See if this is what you are looking for:

SELECT 	RTRIM(CAST(DATEPART(hour, getdate()) AS CHAR))
+ ':' + RTRIM(CAST(DATEPART(minute, getdate()) AS CHAR))
+ ':' + RTRIM(CAST(DATEPART(second, getdate()) AS CHAR))

- Tahsin
Go to Top of Page

shifis
Posting Yak Master

157 Posts

Posted - 2006-03-08 : 16:42:07
Thanks, you undestand what I mean, sorry but sometimes my English is terrible.
Another question how can I obtain for example 14:39:00 insead of
14:39:0?
How can I do that always the hh, mm and second have 2 digits?
Go to Top of Page

Tahsin
Starting Member

34 Posts

Posted - 2006-03-08 : 17:07:02
[code]SELECT CONVERT(VARCHAR,getdate(),108)[/code]

- Tahsin
Go to Top of Page

shifis
Posting Yak Master

157 Posts

Posted - 2006-03-08 : 17:11:01
Thanks a lot
Go to Top of Page
   

- Advertisement -