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
 edit query

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2014-09-01 : 21:59:35
I want to output in yesterday at 20:00 all the sales transaction, but this query is not work , pls help to edit it ?
-----------------------------------------
select * from xsodetail inner join singlepiecemask on singlepiecemask.sku = xsodetail.sku
where
Convert(varchar, GETDATE()-1,112) + LEFT(CONVERT(TIME(0),GETDATE()-1),2)+8 = (xsodetail.txdate-1)+ DATEPART(hour, xsodetail.createdatetime)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-09-02 : 03:01:54
[code]
WHERE xsodetail.createdatetime >= dateadd(day, datediff(day, 0, getdate()), -1) + '20:00'
AND xsodetail.createdatetime < dateadd(day, datediff(day, 0, getdate()), -1) + '21:00'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -