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 |
|
jmersing
Yak Posting Veteran
57 Posts |
Posted - 2011-06-06 : 08:01:52
|
| I have a date and time column that I would like to concatenate. I tried a few variations but nothing seems to work.CAST(TRLogTime AS int) + '-' + TRLogDate AS Expr1TRLogTime + '-' + TRLogDate AS Expr1I would like to add an underscore between the vales as well. |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-06-06 : 08:03:27
|
| try casting as VARCHARhttp://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
jmersing
Yak Posting Veteran
57 Posts |
Posted - 2011-06-06 : 08:17:47
|
| I changed it to Varchar and got a weird result in the Concat column?Time Date Concat64229 20110606 2017483564229 20110606 20174835 |
 |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2011-06-06 : 09:22:20
|
| Try Convert(VARCHAR(20),TRLogTime)+'_'+Convert(VARCHAR(20),TRLogDate) |
 |
|
|
jmersing
Yak Posting Veteran
57 Posts |
Posted - 2011-06-06 : 09:56:04
|
| That did it, thanks so much !! |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-06-06 : 22:26:26
|
| Why do you think that temporal data is strings? That was COBOL, not SQL. Use temporal math to get a timestamp out the two columns.--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|