Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to convert varchar to datetime..



i have uploaded few records into a table where date is varchar

and i need to update to my main database but as both the table is having different datatypes
query is not updating..

kindly help me to convert varchar into datetime ..

i am using ASP.net code
backend- SQL
Posted
Comments
BulletVictim 4-Aug-14 6:11am    
http://stackoverflow.com/questions/10247050/sql-server-convert-varchar-to-datetime
Prasad Avunoori 4-Aug-14 6:11am    
Do you want to update the sql tables datatype?
Please two different records from database with varchar and datetime each.
10923679 4-Aug-14 6:15am    
NO i need to update the time from one table to another
but becos both table is having different datatype(varchar and another is datetime)
so update is not working in asp.net
Prasad Avunoori 4-Aug-14 6:20am    
I am asking you to share/post two records from each table. In which table you want update?
10923679 4-Aug-14 6:22am    
i want to update into main table where datatype is datetime..
from table1 table 2
date(varchar) to date(datetime)

1 solution

SQL
UPDATE M
SET M.UserDate = CONVERT (datetime,T.UserDate,103)
, M.AdviceDate = CONVERT (datetime,T.AdviceDate,103)
FROM Main_Tabl M
INNER JOIN table_temp T ON M.UserNo= T.UserNo
 
Share this answer
 
Comments
10923679 4-Aug-14 6:50am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900