Print Page | Close Window

Adding to the date

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3905
Printed Date: 28 Apr 2024 at 8:02am


Topic: Adding to the date
Posted By: impalacrazy
Subject: Adding to the date
Date Posted: 05 Aug 2008 at 11:33am
So i have raw file that has one date field, My crystal takes that date and addes two time fields to if from that file. i then have two fields the derive from the same date field, however the time in the fields is what is the difference (i.e. DOS = 3/14/08 23:23pm & Triage = 3/14/08 00:10am)
 
now triage should be read as 3/15/08 00:10am as it is the next day. I am trying to compare the hour and add to the date in my code below. Can any help and let me know what i may be doing wrong.
 
 
If Time(hour( mailto:%7b@Arrival - {@Arrival Date})) > Time(hour( mailto:%7b@Triage - {@Triage time}))  then
    date(day( mailto:%7b@Triage - {@Triage time}), day( mailto:%7b@Triage - {@Triage time}), 1)+1
else
    mailto:%7b@Triage - {@Triage time}



Replies:
Posted By: hilfy
Date Posted: 05 Aug 2008 at 12:43pm
The problem is here:
 
 date(day( mailto:%7b@Triage - {@Triage time}), day( mailto:%7b@Triage - {@Triage time}), 1)+1
 
Should be:
 
mailto:%7b@Triage - {@Triage time} + 1
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: impalacrazy
Date Posted: 05 Aug 2008 at 12:50pm
So your saying i should take out the:
 
date(day( mailto:%7b@Triage - {@Triage time}), day( mailto:%7b@Triage - {@Triage time}), 1)+1
 
and replace the whole line with:
 
mailto:%7b@Triage - {@Triage time} + 1
 
I tried that and now no dates show up in the field.
 
Thanks for your help by the way =)


Posted By: hilfy
Date Posted: 05 Aug 2008 at 12:59pm

Let's try simplifying it a little further...  Try this:

 
If hour( mailto:%7b@Arrival - {@Arrival Date}) > hour( mailto:%7b@Triage - {@Triage Time}) then
  mailto:%7b@Triage - {@Triage Time} + 1
else
  mailto:%7b@Triage - {@Triage Time}
 
Since the Hour function returns a number and you're using a 24-hour time, you don't need to convert it back to Time.
 
If that doesn't work, try breaking it down into pieces in multiple formulas to determine what the data actually looks like - for example, make each of these lines a separate formula and put them on your report just to see what the values are:
 
Hour( mailto:%7b@Arrival - {@Arrival  Date})
Hour( mailto:%7b@Triage - {@Triage Time})
mailto:%7b@Triage - {@Triage Time} + 1
 
From there, you should be able to determine what's wrong with your formula.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: impalacrazy
Date Posted: 05 Aug 2008 at 1:33pm
Thanks splitting it up let me see the format on one field was not military so it wasnt calulating correclty. i appreciate all your help.
 
 Wink



Print Page | Close Window