I would like to convert the following Oracle statements to SQL Server statements:
SELECT CAST(e.A_D_V AS DATE) + TO_NUMBER(TO_CHAR(TO_DATE(f.A_T_24, 'HH24:MI:SS'), 'HH24')) / 24 Per
The A_D_V column has a date type in the DB The A_T_24 column has a number(2,0) date type in the DB.
I have tried to following, but the query gives many errors
CAST(e.A_D_V AS DATE) + ' ' + try_CONVERT(char(8), f.A_T_24,108) / 24 Per
You can try the below code in SQL Server.
declare @T VARCHAR(30) = '10:34:54'
declare @D varchar(30) = '2020-05-04'
SELECT CONCAT(CAST(@d as Date), ' ', CAST(DATEPART(HH,CAST(@T AS Time)) AS DECIMAL(4,2))/ 24) as Datevalue
+---------------------+
| Datevalue |
+---------------------+
| 2020-05-04 0.416666 |
+---------------------+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.