Solved

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

Posted on 2006-07-22
6
202 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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