Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Current Date parameters in SQL comand in DB Expert Post Reply Post New Topic
Author Message
bradlee27514
Newbie
Newbie


Joined: 24 Jun 2009
Location: United States
Online Status: Offline
Posts: 20
Quote bradlee27514 Replybullet Topic: Current Date parameters in SQL comand in DB Expert
     Posted: 07 Dec 2010 at 8:32am
I have a query pulling some data in a SQL command

something like  

select
  table.invoicenumber,
  table.invoicedate
from
  table



What I want to do is restrict the records in the SQL command based on the invoicedate field, something like


where
  table.invoicedate =< currentdate and
  table.invoicedate => (currentdate - 3)


So invoices 3 days or older up to today

I know how to do this inside Crystal Reports, however I want to do it in the SQL command before the data even gets there.  This is for several reasons, one of which is to speed up the report running.  Does such syntax exist in SQL, does it know what the current date is?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Dec 2010 at 8:57am
where datediff(day,table.invoicedate,getdate()) between 0 and 3
IP IP Logged
bradlee27514
Newbie
Newbie


Joined: 24 Jun 2009
Location: United States
Online Status: Offline
Posts: 20
Quote bradlee27514 Replybullet Posted: 08 Dec 2010 at 5:21am
works perfectly thanks!
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