sql - how do i get my customer records to still appear in the table beyond the 5 days advance period -
i have query pull out customers records need call within next 5 days in clause as:
remind call =< dateadd(dd,5,getdate() , remind call >= getdate()
the way want work want customers records need call 5 days in advance getdate(). once has entered table, needs stay in table until users enters date 'confirmstart' field on web application.
what happens query displays data should except removes customers record after 5 days want records remain until user has entered date 'confirmstart' field
for example - lets todays date 03/08/2016 want pull out customers need call within next 5 days, therefore in clause wrote:
<remind call =< dateadd(dd,5,getdate() , <remind call >= getdate()
the dateadd should pull out records 08/08/2016. t record id called 'cr1' has remindtocall date 08/08/2013 meet criteria.
the 'cr1' record appears in table great. when getdate() reaches 9/08/2016, 'cr1' record disappears table when want still remain in table until 'confirmedstart' date entered.
how customer records still appear in table beyond 5 days advance period though need records appear 5 days in advance?
further information: elaborate on above example - here sql code 'cr1' record instead of being named 'cr1' in live example cos id record called'1232' - else remains same:
select cosid, surname, firstname, emailaddress, convert (varchar,ukaddressdeadline,103) ukaddressdeadline, convert (varchar,placementstart,103) placementstart, convert (varchar,placementend,103) placementend, convert (varchar,remindtocall,103) remindtocall, extreference, hostorgname, ukendorsement, paymentukba
from dbo.tbl_cos
where
remindtocall between cast('2016-08-03' date) , dateadd(dd,+5, cast('2016-08-03' date)) and
(cosnotrequired null , appwithdrawn = 0 , coswithdrawn = 0 , visarejected = 0 , ukaddressdeadline not null , confirmedstart null or ukendorsement null)
i hope information/details you.
thanks people :d
assuming confirmstart null when no value entered.
add clause
where ( ( [remind call] =< dateadd(dd,5,getdate() , [remind call] >= getdate() ) or ( confirmstart null ) )
Comments
Post a Comment