Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

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

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

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?
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.

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

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.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close