Andrew Angell
asked on
How to convert this time string so I can subtract 5 hours from it...???
AuctionStartGMT = "2006-07-23T04:22:50.776Z"
AuctionStartDate = (Left(AuctionStartGMT,10))
AuctionStartDateSplit = Split(AuctionStartDate, "-")
AuctionStartMo = AuctionStartDateSplit(1)
AuctionStartDay = AuctionStartDateSplit(2)
AuctionStartYear = AuctionStartDateSplit(0)
AuctionStartDate = AuctionStartMo&"/"&Auction StartDay&" /"&Auction StartYear
AuctionStartTimeGMT = Mid(AuctionStartGMT,12,8)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT
What I've got there works to the extent of turning the original time/date format returned into what I want: 07/23/2006 04:22:50
I need to subtract 5 hours from the time, though, because the time here is in GMT. When I try the following, I get an error:
AuctionStartTimeGMT - 5
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "04:22:50"]'
How do I convert that text string into a time that I can then subtract from to convert this? Any information would be greatly appreciated. Thanks!
AuctionStartDate = (Left(AuctionStartGMT,10))
AuctionStartDateSplit = Split(AuctionStartDate, "-")
AuctionStartMo = AuctionStartDateSplit(1)
AuctionStartDay = AuctionStartDateSplit(2)
AuctionStartYear = AuctionStartDateSplit(0)
AuctionStartDate = AuctionStartMo&"/"&Auction
AuctionStartTimeGMT = Mid(AuctionStartGMT,12,8)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT
What I've got there works to the extent of turning the original time/date format returned into what I want: 07/23/2006 04:22:50
I need to subtract 5 hours from the time, though, because the time here is in GMT. When I try the following, I get an error:
AuctionStartTimeGMT - 5
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "04:22:50"]'
How do I convert that text string into a time that I can then subtract from to convert this? Any information would be greatly appreciated. Thanks!
NewDate = DateAdd("h", -5, AuctionStartTimeGMT)
ASKER
Somehow that's bringing back something crazy for a date...even though I'm doing it to the time variable..??? Here's what I've got now...
AuctionStartGMT = "2006-07-23T04:22:50.776Z"
AuctionStartDate = (Left(AuctionStartGMT,10))
AuctionStartDateSplit = Split(AuctionStartDate, "-")
AuctionStartMo = AuctionStartDateSplit(1)
AuctionStartDay = AuctionStartDateSplit(2)
AuctionStartYear = AuctionStartDateSplit(0)
AuctionStartDate = AuctionStartMo&"/"&Auction StartDay&" /"&Auction StartYear
AuctionStartTimeGMT = Mid(AuctionStartGMT,12,8)
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT
response.Write(AuctionStar tTimeStamp )
And I'm getting:
07/23/2006 12/29/1899 11:22:50 PM
So it added 5 hours to the time like it should but it also included a crazy date..??
AuctionStartGMT = "2006-07-23T04:22:50.776Z"
AuctionStartDate = (Left(AuctionStartGMT,10))
AuctionStartDateSplit = Split(AuctionStartDate, "-")
AuctionStartMo = AuctionStartDateSplit(1)
AuctionStartDay = AuctionStartDateSplit(2)
AuctionStartYear = AuctionStartDateSplit(0)
AuctionStartDate = AuctionStartMo&"/"&Auction
AuctionStartTimeGMT = Mid(AuctionStartGMT,12,8)
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT
response.Write(AuctionStar
And I'm getting:
07/23/2006 12/29/1899 11:22:50 PM
So it added 5 hours to the time like it should but it also included a crazy date..??
ASKER
I mean, subtracted 5 hours....
AuctionStartGMT = "2006-07-23T04:22:50.776Z"
AuctionStartTimeGMT = CDate(LEFT(REPLACE(Auction StartGMT, "T", ""), LEN(AuctionStartGMT)-1))
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
Does that work?
AuctionStartTimeGMT = CDate(LEFT(REPLACE(Auction
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
Does that work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That seems to have done it. Thanks!