patticlaire
New Member
- Joined
- Jun 15, 2018
- Messages
- 6
Basically I'm just trying to convert a date and time to a different time zone. Here is my code:
The dateString input is "2018-06-02 20:00". Since I am trying to subtract 7 hours from the time to convert it to a different time zone, I would expect the output, dateofPeak, to be 6/2/2018 1:00:00 PM. However the output I actually get is 6/1/2018 5:00:00 PM.
Any idea what I'm doing wrong?? All the dates that go into the DateAdd function come out as the day before at 5PM. I'm very confused
Code:
dateString = Left(startcell.Offset(i, 0).Value, 10) & " " & Mid(startcell.Offset(i, 0).Value, 12, 5)
dateofPeak = DateAdd("h", -7, DateTime.DateValue(dateString))
The dateString input is "2018-06-02 20:00". Since I am trying to subtract 7 hours from the time to convert it to a different time zone, I would expect the output, dateofPeak, to be 6/2/2018 1:00:00 PM. However the output I actually get is 6/1/2018 5:00:00 PM.
Any idea what I'm doing wrong?? All the dates that go into the DateAdd function come out as the day before at 5PM. I'm very confused