Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

negative time, need to remove "-" 1

Status
Not open for further replies.

gromboy

IS-IT--Management
Mar 12, 2008
67
GB
Hi,
I have the following formula:

numbervar mindiff;
if isnull({PATDRUG.APPT_START})or
trim({PATDRUG.APPT_START}) in [":",""] or
isnull({PATDRUG.PRESC_TIME})or
trim({PATDRUG.PRESC_TIME}) in [":",""] or
isnull({PATDRUG.START_TIME})or
trim({PATDRUG.START_TIME}) in [":",""] or
isnull({PATDRUG.DRUG_TIME})or
trim({PATDRUG.DRUG_TIME}) in [":",""]
then
mindiff := 0 else
mindiff := datediff("n",datetime(currentdate, time({PATDRUG.APPT_START})),datetime(currentdate,time({PATDRUG.DRUG_TIME})));numbervar hrs := truncate(mindiff/60);
numbervar mins := remainder(mindiff,60);
if mindiff = 0 then
"" else
totext(hrs,"00")+":"+totext(mins,"00")

It looks at the difference between 2 times, patient appointment time, and when the drugs are ready. The problem is, a negative character appears for hours and minutes if the first time is greater than the second.

Eg Patient appointment time 13.30, drugs ready 11.50 the output for this is -01:-40

Its putting the negative character for both the hour and minute...

Is there a way of removing this from the minute field ?

Any help greatly appreciated as ever
Steve



 
Either use Abs() or if you instead on replace then just Replace({field},'-','')

'J

CR8.5 / CRXI - Discovering the impossible
 
Hi,
Thanks for your reply...
I added my formula field into the replace formula as

Replace({my_forumula},'-','')

But it didnt do anything...

The abs(my_formula) gave an error "A number or currency ammount is requireed here"

Any ideas ?
Steve
 
The abs would be used on the specific number values:

totext(abs(hrs),"00")+":"+totext(abs(mins),"00")

Did you get an error using:

replace({@formula},'-','')

Or did it simply not have any output?

'J


CR8.5 / CRXI - Discovering the impossible
 
Hey....nice one...that worked a treat !
Thanks a bunch
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top