Calculating completion time

The date construct in UNIX can be used to calculate when something is finished: date -v+1H displays the time 1 hour from now.
I want to use the same construct in a script, but it is leading to error messages:

echo "Finished at: " `date -v+$durationH`

where $duration is calculated based on input variables. Perhaps someone can tell me what construct to use?

Hi.

I tried the construct

date -v+1H

in Linux, Solaris, aix, and hpux without success.

However, if your UNIX allows such usage, I suggest specifying the variable in such a construct in this form:

date -v+${duration}H

that is, curly braces to avoid the ambiguity of a variable named durationH as opposed to duration followed by an H.

Best wishes ... cheers, drl

PS It is always useful to post the error message so that we have a better chance of helping you.

PPS I see that FreeBSD will accept that construct, and the suggested change worked correctly for me.

# var=4
# date -v +${var}H
Sat Apr 18 11:02:40 EDT 2009
# date -v +"$var"H
Sat Apr 18 11:02:44 EDT 2009
# uname
FreeBSD
# echo $SHELL
/bin/bash

Thanks for your reply and for the suggestion to post better error messages. Your suggestions worked. I currently have this:

echo "Finished at: " `date -v+"$duration"H`