Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-07-22
6
Medium Priority
?
207 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

804 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