len() function use
i want to use the Len() function to get the length of the time stamp and then compare the result with some integer value.
I tried to compare the result of Len('time stamp') with the integer value as:
case timestamp
when Len('time stamp')='8' then x
else y
end as result
but this kind of query gives me error.
any help in solving the issue would be appreciated.
Regards,
Dpkas
May 24th, 2011 6:07am
Hi DPKas,
The error is due to the CASE WHEN syntax you have used.
Please try:
case
when Len ('Time Stamp') = 8 then x
else y
end as result
Please check the following link for the Simple Case and a Searched CASE syntax:
http://msdn.microsoft.com/en-us/library/ms181765.aspx
HTH.Please mark correct answers :)
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 6:28am
Hi,
You can also write in this way.
CASE LEN('ABCD')
WHEN 4 THEN 4
ELSE 9
END
Hope its helpful....Pavan Kokkula Tata Consultancy Services.
May 24th, 2011 6:35am
THANKS FOR UR REPLIES..
IT HELPED ME..
REGARDS
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 8:08am