0

I want the date to show 04-23-2021 in one column and the for the second column to show time in a 18:56 format.

I already added the column where its supposed to go to.

I tried these two entries

UPDATE [dbo].[YearlyView]
SET [time_column] = FORMAT(CONVERT(datetime, [time_column]), 'HH:mm')


UPDATE [dbo].[YearlyView]
SET [time_column] = FORMAT(CONVERT(time, [time_column]), 'HH:mm')

This didnt work.

SelVazi
  • 10,028
  • 2
  • 13
  • 29
  • which specific sql are you using? This is for mysql https://stackoverflow.com/questions/12337195/how-to-separate-date-and-time-from-datetime-in-mysql – Popeye May 02 '23 at 22:02
  • ALTER TABLE [APR21] ADD [Started_time] VARCHAR(5); UPDATE [APR21] SET [Started_time] = CONVERT(VARCHAR(5), [started_at], 108); – Louis A May 02 '23 at 22:07
  • If the column is an actual `time` type, **there is no format**. The data is stored as non-human-readable **binary** value. You only format when you `SELECT` data out of the table. Date columns work the same if defined properly. – Joel Coehoorn May 02 '23 at 22:09
  • so you added the column [time_column] and you're trying to set [time_column] by formatting [time_column] which will be full of nulls since you just added it – Kurt May 02 '23 at 22:49
  • Hi - why are you trying to split a single timestamp between two columns when you can just get the result you want when you query the data - or create a view if you don't want to write the SQL each time? – NickW May 03 '23 at 14:33
  • @NickW Hi, Im fairly new to the analysis row so Im trying to clean the data to show in their own columns for me to clean it nicely in tableau. – Louis A May 04 '23 at 14:27
  • Then I would suggest creating a view over the table that does this for you - rather than physically creating additional columns, populating and maintaining them – NickW May 04 '23 at 15:20
  • @NickW Thank you for the feedback! I will look into creating views over tables – Louis A May 04 '23 at 15:36

0 Answers0