maliary Posted April 9, 2009 Share Posted April 9, 2009 Hello, I have this SELECT datediff(day,1999.03.09,1999.03.19) this returns 10. I would like to append the word day to this result. I have tried this SELECT datediff(day,1999.03.09,1999.03.19)+' '+Days but it doesn't work. Any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/ Share on other sites More sharing options...
Mark Baker Posted April 9, 2009 Share Posted April 9, 2009 SELECT CONCAT(datediff(day,1999.03.09,1999.03.19),' Days') Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-805689 Share on other sites More sharing options...
maliary Posted April 14, 2009 Author Share Posted April 14, 2009 It gives an error. Concat is not a recognised built in function name. Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-809620 Share on other sites More sharing options...
PFMaBiSmAd Posted April 14, 2009 Share Posted April 14, 2009 Perhaps if you told us what SQL database type you are using. Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-809656 Share on other sites More sharing options...
maliary Posted April 17, 2009 Author Share Posted April 17, 2009 MSSQL 2005 Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-812150 Share on other sites More sharing options...
mtoynbee Posted April 17, 2009 Share Posted April 17, 2009 Try this: SELECT { fn CONCAT(CAST(DATEDIFF(day, '1999-03-09', '1999-03-19') AS varchar(100)), ' Days') } {edited} or just: SELECT CAST(DATEDIFF(day, '1999-03-09', '1999-03-19') AS varchar(100))+' Days' Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-812314 Share on other sites More sharing options...
maliary Posted April 28, 2009 Author Share Posted April 28, 2009 Thank you very much. That solves it ! Quote Link to comment https://forums.phpfreaks.com/topic/153351-solved-append-string-to-sql-value/#findComment-820906 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.