PDA

View Full Version : gmt function



lior03
06-27-2006, 04:34 AM
hello
this function....

Function gmt(time As Long, diff As Integer) As Long
gmt = time + diff
gmt = Format(gmt, "h:mm:ss")
End Function


is suppose to calculate time difference between time zones.
if the time in germany is 17:00:00 and the time difference betwween israel and germany is 1 hour(diff) then the result should be 18:00:00.
i also would luke to get the result formated.
thanks

Bob Phillips
06-27-2006, 06:47 AM
hello
this function....

Function gmt(time As Long, diff As Integer) As Long
gmt = time + diff
gmt = Format(gmt, "h:mm:ss")
End Function

is suppose to calculate time difference between time zones.
if the time in germany is 17:00:00 and the time difference betwween israel and germany is 1 hour(diff) then the result should be 18:00:00.
i also would luke to get the result formated.
thanks

You need to pass the time as a double not long, and as your code is, the function needs to be type string, not long



Function gmt(time As Double, diff As Integer)
gmt = time + diff / 24
gmt = Format(gmt, "h:mm:ss")
End Function


However, I would pass back a double and format the cell


Function gmt(time As Double, diff As Integer) As Double
gmt = time + diff / 24
End Function

mdmackillop
06-27-2006, 06:56 AM
If you feel like being a little more ambitious, have a look here.
http://www.cpearson.com/excel/timezone.htm