Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula to compare datetime to currentdatetime Crystal XI

Status
Not open for further replies.

jpeters01

Technical User
Dec 5, 2007
109
US
I need the date to display only if it is greater than the currentdatetime. Please tell me why this formula does not work...it displays dates that are both greater than and dates that are less than the CurrentDateTime. The {table.startdate} is a datetime field.


if isnull ({table.startdate}) then ' '
else if {table.startdate} > (CurrentDateTime) then totext ({table.startdate},"MM/dd HH:mm")

I have also tried:

if isnull ({table.startdate}) then ' '
else if {table.startdate} > (CurrentDateTime) then totext ({table.startdate},"MM/dd HH:mm")
else if {table.startdate} < (CurrentDateTime) then ''

 
How do you know what you are seeing if you don't format the date to show the year? Your first formula should work. I would just add in the year so you could verify the result.

-LB
 
Hi LB, I had also put the {table.startdate} field on the report so I knew what the year was. I did find that when I added the CurrentDateTime field to the report it said 10/3/2006 10:59:45 AM. I saw that under Report, Set Print Date and Time it had been set to 10/3/2006 10:59:45 AM. When I changed the Set Print Date and Time to Today's Date and Time, the CurrentDateTime displayed correctly on the report and the formula worked. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top