Created
June 28, 2016 09:03
-
-
Save dexMargera/1d02299cb822810dc901fcf0770dd6b7 to your computer and use it in GitHub Desktop.
trunc like oracle in mssql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mssql: | |
SELECT CONVERT(DATETIME, ((CONVERT(VARCHAR(10), GETDATE(), 104)) + ' ' + (CONVERT(VARCHAR(2), GETDATE(), 8)) + ':00:00')); | |
SELECT CONVERT(DATETIME, ((CONVERT(VARCHAR(10), GETDATE(), 104)) + ' ' + CONVERT(VARCHAR(2), ((CONVERT(VARCHAR(2), GETDATE(), 8))-1)) + ':00:00')); | |
oracle: | |
SELECT trunc(sysdate, 'hh24') FROM dual; | |
SELECT trunc(sysdate, 'hh24')-1/24 FROM dual; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment