PDA

View Full Version : rest 2 hours to the system hour



mahoni
01-23-2007, 09:29 AM
I have got this code:
formatHour=FormatDateTime(Now,4)
hour=Mid(formatoHour,1,2) & Mid(formatoHour,4,1) & "0"

formatHour has got (for example) 10:15
then hour has got 1000

i want to rest 2 hours to the system hour, but i donot know.
I would want that formatHour have 8:15

Thankyou

Be careful with this:
If the system hour is 0:00 the desired hour should be: 22:00

IronNadz
02-17-2007, 04:45 PM
the easiest way is to merely use dateadd thusly:

NewTime=dateadd("h",-2,formatHour)

NewTime will now contain the time in formathour minus two hours. It will work for any valid time of the day