Solved

convert date to text

Posted on 2008-06-09
3
850 Views
Last Modified: 2012-05-05
I am trying to concatenate 2 attributes of different data types...

One is date (TRANS_DT), and another one is text (Customer_Name)

I am usign the following query

select
(TRANS_DT+Customer_Name) as key_combo
from
table_A

getting an error message
"Syntax error converting datetime from character string."

Please advice...
0
Comment
Question by:redgreenred
  • 2
3 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 21745519

select
(cast(TRANS_DT as varchar(30)) +Customer_Name) as key_combo
from
table_A
0
 

Author Comment

by:redgreenred
ID: 21745607
getting the same error message

"Syntax error converting datetime from character string"
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 50 total points
ID: 21745619
select
(convert(varchar(10), TRANS_DT, 112) +Customer_Name) as key_combo
from
table_A
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question