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
 General SQL Server Forums
 New to SQL Server Programming
 replace get() and datepart

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2014-09-10 : 05:15:05
Anyone can help edit this query, I don't want use the getdate() and datepart this command but keep the result. because my third party software products cannot recognize this command.

----------------------------------------------------------
select shopcode,createdatetime, memono,actualsalesamt from xsoheader where shopcode like '%5%' and txdate=convert(char(8),getdate(),112)and datepart(hour,createdatetime)<17 and actualsalesamt>0

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-10 : 08:17:35
Use SYSDATETIME instead of GETDATE() and use "CAST(createdatetime as TIME) < '17:00'" instead of "DATEPART(hour, createdatetime) < 17"

However, I doubt if the third party system that doesn't recognize GETDATE and DATEPART would have snowball's chance in hell of recognizing SYSDATETIME and TIME data type.
Go to Top of Page
   

- Advertisement -