Update Table Set B = Replace(Convert(char(19), A, 120), '-', '/');
Tom
SQL : How to convert datewith timestamp to varchar
kkran
831
Reputation points
Hello team - I have a column A with the value '2020-05-01 02:01:55.000'. I want to update column B getting the value from column A convert into '2020/05/01 02:01:55'.
Update Table
Set Column B = Column A
Column B is varchar and Column A is Datetime.
Could you please help.
Thanks
2 answers
Sort by: Most helpful
-
Tom Cooper 8,466 Reputation points
2022-02-17T20:41:33.16+00:00 -
Suresh Wijesundara 1 Reputation point
2022-02-18T11:42:12.053+00:00 Update Table
Set [Column B] = CONCAT_WS(' ',CONVERT( varchar, [Column A], 111) , CONVERT(varchar, [Column A], 108))