Solved

How to convert this time string so I can subtract 5 hours from it...???

Posted on 2006-07-22
6
199 Views
Last Modified: 2006-11-18
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&"/"&AuctionStartDay&"/"&AuctionStartYear
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!



0
Comment
Question by:Andrew Angell
  • 3
  • 3
6 Comments
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17162260
NewDate = DateAdd("h", -5, AuctionStartTimeGMT)
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 17162280
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&"/"&AuctionStartDay&"/"&AuctionStartYear
AuctionStartTimeGMT = Mid(AuctionStartGMT,12,8)
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT

response.Write(AuctionStartTimeStamp)

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..??
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 17162282
I mean, subtracted 5 hours....
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17162324
AuctionStartGMT = "2006-07-23T04:22:50.776Z"
AuctionStartTimeGMT = CDate(LEFT(REPLACE(AuctionStartGMT, "T", ""), LEN(AuctionStartGMT)-1))
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)

Does that work?
0
 
LVL 26

Accepted Solution

by:
DireOrbAnt earned 500 total points
ID: 17162330
From you previous code replace that:
AuctionStartTimeGMT = DateAdd("h", -5, AuctionStartTimeGMT)
AuctionStartTimestamp = AuctionStartDate&" "&AuctionStartTimeGMT

With this:
AuctionStartTimestamp = DateAdd("h", -5, AuctionStartDate & " " & AuctionStartTimeGMT)

DateAdd require a full date, so it added the default start date of 12/29/1899
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 17162345
That seems to have done it.  Thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now