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.
| Author |
Topic |
|
Rupa
Posting Yak Master
123 Posts |
Posted - 2007-11-08 : 09:17:44
|
| Hey allI have a date in the following format: 08/11/2007 13:57:26I would like to get 13:57 I'm using RIGHT(PrintDate, 7) which gives me: 1:56PMHow can I get 13:57 on its own??Any response will be highly appreciated.Many thanks,Rupa |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2007-11-08 : 09:31:35
|
| so you're casting it as a string? if you just want to seperate the time portion you'd be better to keep it as a datetime...select getdate()-dateadd(dd,datediff(dd,0,getdate()),0) as time_onlythat way you can still 'use' it for queries etc.Em |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2007-11-08 : 09:36:46
|
| or if you do really really want a character string. maybe...select cast(datepart(hh,getdate())as char(2))+ ':' + cast(datepart(ss,getdate()) as char(2))Em |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-08 : 09:39:42
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65358 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Rupa
Posting Yak Master
123 Posts |
Posted - 2007-11-08 : 09:47:23
|
| Thx Em...This worked for me:CONVERT(VARCHAR(5),PrintDate, 108)Thx KH Rupa |
 |
|
|
|
|
|