Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date and Time Math Post Reply Post New Topic
Author Message
tdavenport
Groupie
Groupie
Avatar

Joined: 21 Oct 2008
Location: United States
Online Status: Offline
Posts: 41
Quote tdavenport Replybullet Topic: Date and Time Math
     Posted: 03 Jul 2009 at 9:18am
I need to calculate the difference between two date and time fields and return a number.
 
I have a target date field and a target time field. I need to subtract this from the complete date field and complete time field. The result will be either a positive or negative number. How do I do this?
 
I thought I'd simply need to combine the date and time fields and then do simple math ... but I'm not sure how to combine the date and time fields into a single value.
 
Any and all suggestions are appreciated.
 
Thank you.
Any and all suggestions are welcome.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 06 Jul 2009 at 6:45am
dateTime(date, time)
 
so you could do something like:
local datetimevar target := datetime({target.date},{target.time});
local datetimevar complete := datetime({complete.date},{complete.time})
datediff(s,complete,target)
 
will give the difference in seconds, then you can convert or you can select a different unit of measure (see datediff function in Crystal Help.
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