Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date Diff Post Reply Post New Topic
Author Message
dnrwilbl
Newbie
Newbie


Joined: 23 Mar 2009
Location: United States
Online Status: Offline
Posts: 6
Quote dnrwilbl Replybullet Topic: Date Diff
     Posted: 14 Aug 2009 at 12:58pm
I have an access query that I'm using as my source of data.  In it there are two dates and in my Crystal Report, I'm trying to find the number of days difference between the two.  My formula is: datediff ("d",{table.date1},{table.date2}.  I get an error that states a date is required instead of {table.date1}.  Any suggestions?  Thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 14 Aug 2009 at 1:34pm
What type of database are you using? What is the actual data type of the fields that contain the date data?  Just because the field name has "Date" in it, doesn't mean that the data is stored in a Date format.
 
-Dell
IP IP Logged
dnrwilbl
Newbie
Newbie


Joined: 23 Mar 2009
Location: United States
Online Status: Offline
Posts: 6
Quote dnrwilbl Replybullet Posted: 14 Aug 2009 at 2:03pm
It is access and I have the field formated to be a date
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 16 Aug 2009 at 9:16am
If these are date fields with no time component (or if the time component from both is 12:00:00 AM), you can just use {table.date2} - {table.date1} instead of using DateDiff.  If there is a time component you can do something like this:
 
({table.date2} - {table.date1) \ 1
 
Note that this uses backslash '\' which is the modulus operator instead of slash '/' which is the division operator.  Modulus gives you the whole number part of the equation.  You would want to use this instead of Round because Round will round up the number if there is more than 12 hours difference.
 
-Dell
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