Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 PLSQL DATE TO TSQL

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-03-04 : 12:56:33
convert this plsl to tsql
BAL.LAST_UPDATE_DATE> sysdate-1
BAL.LAST_UPDATE_DATE<= sysdate

this should return only records based on the last update date and the day prior.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-03-04 : 13:39:36
This probably is not equivalent to the query you posted, but I think it meets the textual description of what you wanted:
BAL.LAST_UPDATE_DATE >= DATEADD(DAY, -1, CAST(SYSDATETIME() AS DATE))
AND BAL.LAST_UPDATE_DATE < CAST(SYSDATETIME() AS DATE)
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2014-03-04 : 13:58:07
If SysDate in oracle/PL SQL, refers to the "date and time", then I think the equivalent would be to use Lamprey's query as


BAL.LAST_UPDATE_DATE >= DATEADD(DAY, -1, CAST(SYSDATETIME() AS DATETIME))
AND BAL.LAST_UPDATE_DATE < CAST(SYSDATETIME() AS DATETIME)

in order to account the "time" factor.

Note: you can use SysDateTime() as well as GetDate() as far as the above piece of code is concerned. The difference in both is that, in sql server, SysDateTime has more fractional seconds precision than getdate(). Check MS documentation for more details.

Cheers
MIK
Go to Top of Page
   

- Advertisement -