1:To convert 280908(ddmmyy) to 2008-09-28 00:00:00.000
a- SELECT CONVERT(DATETIME, STUFF(STUFF('280908',3,0,'/'),6,0,'/'), 3)
b- declare @tst Varchar(6)
Set @tst = '280908'
Select cast(substring(@tst,3,2) + '/' + left(@tst,2) + '/' + right(@tst,2) as datetime)
2:Number of weeks between two different dates
SQL :SELECT DATEDIFF (ww, '01/01/1753', '12/31/9999');
ORACLE:SELECT floor(
(to_date('12/31/9999','mm/dd/yyyy')
- to_date('01/01/1753','mm/dd/yyyy')
)
/ 7) diff
FROM DUAL;
a- SELECT CONVERT(DATETIME, STUFF(STUFF('280908',3,0,'/'),6,0,'/'), 3)
b- declare @tst Varchar(6)
Set @tst = '280908'
Select cast(substring(@tst,3,2) + '/' + left(@tst,2) + '/' + right(@tst,2) as datetime)
2:Number of weeks between two different dates
SQL :SELECT DATEDIFF (ww, '01/01/1753', '12/31/9999');
ORACLE:SELECT floor(
(to_date('12/31/9999','mm/dd/yyyy')
- to_date('01/01/1753','mm/dd/yyyy')
)
/ 7) diff
FROM DUAL;
No comments:
Post a Comment