May 4, 2005 at 10:08 am
Hi all,
I want to convert int type to varchar type. Basically i'm using datediff which returns integer value but when i try to convert this into varchar or char then it results in an error..my current sql statement is
select convert(varchar,planarrvtime,108) as plantime,
convert(varchar,arrtime,108) as arrvtime,
DATEDIFF(hour, planarrvtime, arrtime) as diff,
case DATEDIFF(hour, planarrvtime, arrtime) when 0 then convert(int(5), CONVERT(varchar(20), 'p'))
else DATEDIFF(hour, planarrvtime, arrtime) end
from time
i want to show p or some other value like present if the difference is 0
thanks in advance....
May 4, 2005 at 4:18 pm
I think you are getting a bit mixed up with your CONVERT statements
select convert(varchar(20),planarrvtime,108) as plantime,
convert(varchar(20),arrtime,108) as arrvtime,
DATEDIFF(hour, planarrvtime, arrtime) as diff,
case DATEDIFF(hour, planarrvtime, arrtime) when 0 then 'Present'
else CAST(DATEDIFF(hour, planarrvtime, arrtime) AS VARCHAR(10)) end
from time
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply