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
 Analysis Server and Reporting Services (2005)
 SQL Script

Author  Topic 

tahseenm
Yak Posting Veteran

64 Posts

Posted - 2012-10-19 : 11:04:57
I am trying to retrieve the data from one of the table and not returning anything and no errors. Can somebody help me out on this anything I am putting is wrong. Here is the script below to return field search by a particular date. Thanks

select adddttm,refundamount,moddttm,refundeddttm,refundstatusdttm
from billing.refund where adddttm='08/22/2012'





moetahsen

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-19 : 11:33:20
First, see if there is any data in the table at all.
SELECT TOP 10 adddttm,
refundamount,
moddttm,
refundeddttm,
refundstatusdttm
FROM billing.refund
If there is, try changing the where clause to one of these:
WHERE  adddttm = CAST('08/22/2012' AS DATETIME)
WHERE CAST(adddttm AS DATETIME) = CAST('08/22/2012' AS DATETIME)
WHERE adddttm >= CAST('08/22/2012' AS DATETIME) AND addttm < CAST('08/23/2012' AS DATETIME)
If none of that seems to work, post the results of this query:
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.[COLUMNS] c
WHERE c.TABLE_NAME = 'refund' AND c.TABLE_SCHEMA = 'billing'
AND c.COLUMN_NAME = 'adddttm'
Go to Top of Page

tahseenm
Yak Posting Veteran

64 Posts

Posted - 2012-10-19 : 11:58:19
WHERE adddttm >= CAST('08/22/2012' AS DATETIME) AND adddttm < CAST('08/23/2012' AS DATETIME)

The above script works and thanks for the time.

moetahsen
Go to Top of Page

tahseenm
Yak Posting Veteran

64 Posts

Posted - 2012-10-19 : 12:01:43
Just want to let you know that I check the datatype by using your script and its

datetime

moetahsen
Go to Top of Page
   

- Advertisement -