Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: [resolved]: Difference between dates Post Reply Post New Topic
Author Message
carine
Newbie
Newbie


Joined: 27 Jun 2013
Location: Brazil
Online Status: Offline
Posts: 14
Quote carine Replybullet Topic: [resolved]: Difference between dates
    Posted: 11 Sep 2013 at 7:57am
Good afternoon!

I wonder how do I get the difference between two dates.
I have two fields of type "date time".

example:

Student         Date                         Date request                         authorization
----------------------------------------- ------------------------------------------------------

Alan           17/06/2013  12:00:00    17/06/2013 18:00:00                     4h
Julia            17/06/2013 12:00:00     18/06/2013 18:00:00               1d 4h


The result may be only days or hours ... whatever as long as I can show the time of authorization.
How would I do that?


Edited by carine - 12 Sep 2013 at 4:27am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Sep 2013 at 11:34am
you have to choose the lowest amount of time you want to look at and use that in a datediff function. Your result can then be displayed in different text formating...
e.g. datediff("h",date,daterequest) will give you the difference in hours but note that 1 minute can look like an hour if it compares "7:59 pm" and "8:00 pm"
once you get the hour value (or you can use whatever time portion if you want) you can use a calcuation to turn that into days and hours.


Edited by DBlank - 11 Sep 2013 at 11:35am
IP IP Logged
carine
Newbie
Newbie


Joined: 27 Jun 2013
Location: Brazil
Online Status: Offline
Posts: 14
Quote carine Replybullet Posted: 12 Sep 2013 at 3:04am
Good day!

I put the formula you said but I think the result is going wrong.

Formula
: DateDiff ("h", {AGR_ASSINATURAS_V.DAT_EMISSAO},{AGR_ASSINATURAS_V.DAT_LIBERACAO})

Student         Date                         Date request               authorization
-----------------------------------------------------------------------------------


Alan        06/06/2013 00:00:00      07/06/2013 09:13:05    7,00

this result is that? In hours?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Sep 2013 at 3:52am
the results is the total number of hour between the two dates it should return 33.
I believe that the datdiff finction always expects the "Month-day-year" sequence so you wold need to convert your field to use that.
IP IP Logged
carine
Newbie
Newbie


Joined: 27 Jun 2013
Location: Brazil
Online Status: Offline
Posts: 14
Quote carine Replybullet Posted: 12 Sep 2013 at 4:25am
Great!

I created a field to receive the values ​​of "date time" and turns only "date" and did the calculation on just the date fields.
Made this solved my problem.

Thank you!
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.