Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Include Records on File for X number of Days Post Reply Post New Topic
Author Message
Dawn08
Newbie
Newbie


Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 22
Quote Dawn08 Replybullet Topic: Include Records on File for X number of Days
     Posted: 17 Aug 2012 at 3:38am
I could use some expert advise on how to tackle this problem...:)
 
I'm creating a report that includes active and terminated employees. The terminated employees need to drop off the file after X number of days. I was going to include terms for a 14 day look back period, then drop them from the file.
 
EEstatus = 'Terminated'   and    
EEtermdate between (currentdate - 14 days) and Getdate()
 

where the start is dynamically generated using the currentdate, accounting for crossing into a prior month scenarios. 

  

Any suggestions would be great appreciated!!!
 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Aug 2012 at 3:49am
isnull(table.EEtermdate)
or
(table.EEstatus = 'Terminated'   and    
datediff('d',table.EEtermdate,currentdate) in 0 to 14)
IP IP Logged
Dawn08
Newbie
Newbie


Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 22
Quote Dawn08 Replybullet Posted: 17 Aug 2012 at 5:42am
Thank for the feedback.
 
I tried the following in the SQL statement, but I'm getting a error of
"invalid parameter 1 specified for datediff"
 
Any suggestions???
 
 
FROM
    EBASE    
inner join EEmploy on EBflxid = EEflxideb AND     
(EEdatebeg <= GetDate() and EEdateend >= GetDate() or EEdateend is null) AND     
(EEstatus <> 'Terminated' or EEstatus = 'Terminated' and (EETermdate = datediff('d',EEmploy.EEtermdate,currentdate) in 0 to 14))
inner join EJob on EBflxid = EJflxideb   and
(EJdatebeg <= GetDate() and  
(EJdateend > = GetDate() or EJdateend is null) AND 
(EEstatus <> 'Terminated' or EEmploy.EEstatus = 'Terminated' and EJDATEEND = EETERMDATE)) 
WHERE
    EBASE.EBFLAGEMP = 'Y'
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Aug 2012 at 6:23am

are you trying to add a crystal select statement or alter your source?

IP IP Logged
Dawn08
Newbie
Newbie


Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 22
Quote Dawn08 Replybullet Posted: 17 Aug 2012 at 6:37am
 
I was trying to retrieve the correct records with the SQL statement, not using an additional Select....but I'm not opposed to that approach.
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Aug 2012 at 6:59am
ahhh. I was giving you a crystal select statement. You could ajdust your sql join statement or add a where clause.
 
sql uses different syntax
 
first you are not trying to making it = anything
 
and (EETermdate = datediff('d',EEmploy.EEtermdate,currentdate) in 0 to 14)
next using SQL instead of crystal it converts to
 
 
datediff(day,EEmploy.EEtermdate,getdate()) between 0 and 14


Edited by DBlank - 17 Aug 2012 at 6:59am
IP IP Logged
Dawn08
Newbie
Newbie


Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 22
Quote Dawn08 Replybullet Posted: 17 Aug 2012 at 8:18am
Thank you very much. That worked !!!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum