How to remove date from datetime data type

Hi,
I have a stored proc with datetime as data type. I need only time from that.
ALTER PROCEDURE [dbo].[MarketResearch]
AS
BEGIN
select current_count as CurrentCount,
CAST(progress_info as datetime) progressinfo,

from dbo.market

return 0;
end
this stored proc is returning date and time. i just need time from this. can you guys help me how to format?
Thanks.

select convert(varchar(100), getdate(), 114) might work?

select convert(varchar(100), getdate(), 9) union all
select        convert(varchar(100), getdate(), 109) union  all
select 	   convert(varchar(100), getdate(), 13) union  all
select 	   convert(varchar(100), getdate(), 113) union  all
select 	   convert(varchar(100), getdate(), 114) union  all
select 	   convert(varchar(100), getdate(), 20) union  all
select 	   convert(varchar(100), getdate(), 120) union  all
select 	   convert(varchar(100), getdate(), 21) union all
select 	   convert(varchar(100), getdate(), 121) union all
select 	   convert(varchar(100), getdate(), 126) union all
select 	   convert(varchar(100), getdate(), 127) union all
select 	   convert(varchar(100), getdate(), 130) union all
select 	   convert(varchar(100), getdate(), 131) 

how can you format the above stored procedure?

is progress_info a real datetime datatype column?

ALTER PROCEDURE [dbo].[MarketResearch]
AS
BEGIN
select current_count as CurrentCount, 
CAST(progress_info as datetime) progressinfo,
convert(varchar(100), progress_info, 114)

from dbo.market

select current_count as CurrentCount,
CAST(progress_info as time) progressinfo,

the data type in sql table is 'Time' i wanted to change to datetime that is why i am using cast. now the result is date and time. i want to eliminate the date. any idea?
Thanks

progress_info data type is 'time' that is why i am using CAST to change to datetime. now i want to take only time from this.
Thanks

convert() method takes 3 parameters

  1. datatype
  2. Column/Value
  3. Style: Available styles are from 100 to 114. You can choose within range from. Choose one by one to change the date format.

convert(varchar(250), progress_info, 108)

This does not make sense - if the column is already time then why cast to datetime if you want return the time? Is there something else you are doing that is not included in that procedure?

1 Like