Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

#### Feedback

"...I also believe that we all can contribute to each other's growth by sharing knowlege and experiences. I would love to take my skills and help people around the world solve problems..."

#### Geography

Where in the world do Tek-Tips members come from?

# DateDiff returning wrong value

 Forum Search FAQs Links Jobs Whitepapers MVPs
 huddy33 (TechnicalUser) 15 May 12 16:18
 I have the following formula for calculating the difference between two dates. I need to run a calculation once I get the correct value.DateDiff("d",{Meeting.TravelStartDate},{Meeting.TravelEndDate})The date set for this particular report is 4/29/12 to 5/4/12. It spans two months and a weekend. The formula above is returning 5 when it needs to return 6. I've tried everything, please help!
 briangriffin (Programmer) 15 May 12 17:57
 Look at it this way - if your dates were 4/1 and 4/30, that would encompass 30 days. But the difference is 29: 30 - 1.If you need that extra day just add it in your formula:DateDiff("d",{Meeting.TravelStartDate},{Meeting.TravelEndDate}) + 1
 huddy33 (TechnicalUser) 15 May 12 18:08
 I have tried that but then any date set that doesn't hit that month switch is over by one.
 Madawc (Programmer) 16 May 12 9:35

#### Quote:

any date set that doesn't hit that month switch is over by one
That doesn't make sense. Print out a calendar and try numbering the days, I think you'll find the calculation is correct.

If you want something different when the two dates are in different months, you can make a formula field testing Month(YourDate). Also Year(YourDate) is the two dates might occasionally be in the same date of different years.

Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP

 briangriffin (Programmer) 16 May 12 9:58
 Months, years, and even leap years are all taken into account within the datediff function. You should only have to add one day regardless of the start and stop dates, but please provide two dates where that calculation is incorrect and we can figure out what is happening.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!