Showing posts with label entered. Show all posts
Showing posts with label entered. Show all posts

Saturday, February 25, 2012

Records last month

Today's month is 9 as in September. How can I retrieve records entered last month?

This is what I got so far...

WHERE (Classes.CLWhenDt >= DATEADD([MONTH], - 1, GETDATE()))

WHERE MONTH(Classes.CLWhenDt)=8

OR

WHERE Classes.CLWhenDt > '07/31/2006' AND Classes.CLWhenDt <'09/01/2006'

|||

OR

WHERE DATEDIFF(m,Classes.CLWhenDT,getutcdate())=1

Or this will perform faster:

WHERE Classes.CLWhenDT>=DATEADD(m,DATEDIFF(m,0,getutcdate())-1,0) AND Classes.CLWhenDT<DATEADD(m,DATEDIFF(m,0,getutcdate()),0)

|||Thanks for all your replies. I used this one "WHERE Classes.CLWhenDt > '07/31/2006' AND Classes.CLWhenDt <'09/01/2006'" as a temp solution but I will try your reply Motley.|||

Actually, that will catch dates that part way through 7/31. You should use:

WHERE Classes.CLWhenDt>='08/01/2006' AND Classes.CLWhenDt<'09/01/2006' instead, unless you are sure that CLWhenDt never contains a time component (aka always set to midnight).

Monday, February 20, 2012

Record Selection - CR9

Hi

I want my report to output data if any one of three date fields is greater or equal to today.

In my record selection i entered "datefield1" >= currentdate OR "datefield2" >= currentdate OR "datefield3" >= currentdate. However, report itself seems to only act after the first datefield is true and does not output data if the others are true. Crystal seems to ignore the subsequent record selections...

Where am I going wrong? Thanks...this is the code that is not working fully.. I have also tried xor

{tblKeyDates.datPODDue}>= currentdate or
{tblKeyDates.datHearing}>= currentdate or
{tblKeyDates.datPt8Iss}>= currentdate|||Is what you've shown the entire record selection formula?