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 2005 Forums
 Transact-SQL (2005)
 Query is correct but didn't bring a result

Author  Topic 

dorothykunth
Starting Member

2 Posts

Posted - 2014-11-07 : 06:48:05
Hi I created a query to show the list of PO's created today (current date) and are over 5000. But the query didn't bring any result. I'm running on SQL 2005. Here is the query:
SELECT T0.[DocDate] as 'PO Date', T0.[DocNum] as 'PO Number', T0.[CardCode] as 'Vendor Code', T0.[CardName] as 'Vendor Name', T0.[DocTotal] as 'PO Amount' FROM OPOR T0 WHERE T0.[DocTotal] > 5000 and T0.[DocDate] = (CONVERT(datetime, GETDATE()))

Not sure if it has something to do with the date format or something.
Please help

Many thanks
DKunth

Ifor
Aged Yak Warrior

700 Posts

Posted - 2014-11-07 : 08:04:11
Try replacing:

T0.[DocDate] = (CONVERT(datetime, GETDATE()))


with:

T0.DocDate = DATEADD(day, DATEDIFF(day, 0, CURRENT_TIMESTAMP), 0)
Go to Top of Page

dorothykunth
Starting Member

2 Posts

Posted - 2014-11-07 : 09:29:57
Many thanks Ifor. Now it works
Go to Top of Page
   

- Advertisement -