?
Solved

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

Posted on 2006-07-22
6
Medium Priority
?
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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