Click here to Skip to main content
15,919,931 members

Comments by Kristian_dk (Top 39 by date)

Kristian_dk 20-Mar-17 5:50am View    
Found the solution finally:
,Convert(DATE, LEFT(CREATED, 8)) AS CREATIONDATE
That did the trick..

Thanks for helping out.. I have never thought about the Int vs. String confusion..
Kristian_dk 18-Mar-17 18:00pm View    
Of yes it is true. Just checked the columne. Its a Interger.
Kristian_dk 18-Mar-17 11:43am View    
This code throws a:
Msg 8116, Level 16, State 1, Line 2
Argument data type int is invalid for argument 1 of substring function.
Kristian_dk 18-Mar-17 11:43am View    
I cant really get your code to work. CREATED is my timestamp with format yyyymmddhh.
SELECT CAST(SUBSTRING(CREATED, 1, 4) + '-' + SUBSTRING(CREATED, 5, 2) + '-' + SUBSTRING(CREATED, 7, 2) + ' ' + SUBSTRING(CREATED, 9, 2) + ':00' AS DATETIME)
,[USERNAME]
,[USERTYPE]
,[CREATED]
,[USED]
,[USERNAME2]
,[EMAIL]
FROM [EDW].[User]
Kristian_dk 18-Mar-17 11:37am View    
I do unfortunatly not have access to change anything on the database since it is an old application i have to do some reporting on. But I will clearly try to get the storing of dates changed to datetime for the future.