SQL : How to convert datewith timestamp to varchar

kkran 831 Reputation points
2022-02-17T20:16:38.407+00:00

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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,910 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,563 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tom Cooper 8,466 Reputation points
    2022-02-17T20:41:33.16+00:00
    Update Table Set B = Replace(Convert(char(19), A, 120), '-', '/');
    
    Tom
    
    0 comments No comments

  2. 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))

    0 comments No comments