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
 status

Author  Topic 

maggie21620
Starting Member

27 Posts

Posted - 2013-10-16 : 16:24:05
i have a qry that brings back a delete date of the previous day when something was scheduled for deletion and I want to be able to see if the deletion actuall occurred and what the current status of the item is. I have this and it works fine to show me the status of F for deleted but i want to add another field to tell me if it actually was deleted. is that possible to do keeping in mind that our data is one day behind.

In short how can i see the status for the box numbers that were set up to delete the day before

SELECT DISTINCT [ACCTCORP]
,[BNUMB]
,[PREVHOUSE]
,[BXSTATUS]
--,[FMT]
--,[PROM]
,[HUB]
,[DELDATE]
,[OPR]
,[MODEL]
,[MACADDRESS]
,[EQUIP_VERSION]
,[SUBSCRIBEROWNED_FLG]
,[ADDRESS_TYPE]

--,[LAST_UPDATE_DATE]
FROM [infoDDP].[dbo].[IDST_BOX_INVENTORY]
WHERE
DELDATE BETWEEN CONVERT(VARCHAR(10), GETDATE() - 1, 101)
AND DATEADD(d, -1, (DATEADD(hh, 23, (DATEADD(mi, 59, (DATEADD(ss, 59, (DATEADD(ms, 997, CONVERT(VARCHAR(10), GETDATE(), 101))))))))))
AND BXSTATUS <> ('D') AND SUBSCRIBEROWNED_FLG = '1'

none

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-10-16 : 17:14:26
Not sure what the rules are for that - Is it as simple as this?


select [BXSTATUS]
, [BNUMB]
from [infoDDP].[dbo].[IDST_BOX_INVENTORY]
where [DELDATE] >= dateadd(day, datediff(day, 1, getdate()), 0) --yesterday 12:00 AM
and [DELDATE] < dateadd(day, datediff(day, 0, getdate()), 0) --today 12:00 AM




Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-17 : 04:19:29
also see
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -