sql - How to separate this field into two columns -
I have found a simple problem to solve, which would normally be quite simple. I have a field that contains a DateTime part, as well as a trailing part. Now I need to split this field into two discrete areas - date time and worker. Now to capture a bit of the data, the data has been saved with two different date formats, which results in 'very' like this:
revision --------- ----- --------------------------------------------- ----- ----- 30/07/2010 11:39:55: Change of booking status on cancellation option 5/5/2010 10: 1: 8: new
As you can see, the dates are in two completely different formats. I would like to see it somehow like:
dateofnote | pay attention ------------------------------------------------ - --------------------- 30/07/2010 11:39:55 | Change of booking status on cancellation option 05/05/2010 10:01:08 | = "text"> Easily? Yes, if we can do some assumptions, if this is the case that there is no colon in the text, then you can:
declare the data table (Max) Enter @ Data (Data) value ('30/07/2010 11:39:55: Changing from option to cancel booking option)' Insert @ data (data) value ('5/5 / 2010 10: 1: 8: New ') Set Date Format DMY Cast Cast (Reverse (Substring) (Reverse (Data), F (Index: ',', reverse (data)) + 1, datetime), LTRI (reverse (reverse (data), 1, four index (':', reverse ) - 1))) @data
Comments
Post a Comment