Solved

How to change value of hours and seconds in the same date string?

Posted on 2016-10-27
3
39 Views
Last Modified: 2016-10-28
I have a vba dateString variable in "longTime format" that is uncorrected for daylight saving,
I must adjust the hours value by -1, and then I need to adjust the seconds value by -1

Dim strDate As String
Dim dtDate As Date

The model of my string date:
      strDate = Format(Time, "Log Time")n
I can change the hour parameter in that date
      dtDate = DateAdd("h", -1, strDate)
or the second parameter
      dtDate = DateAdd("s", -1, strDate)

But how do I change BOTH parameters in the same date?
    ("s", -1, strDate) and ("h", -1, strDate)

Thanks
Kelvin
0
Comment
Question by:Kelvin4
[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 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 250 total points
ID: 41863444
try this:
dtDate = DateAdd("h", -1, strDate)
    dtDate = DateAdd("s", -1, dtDate)

Open in new window

or
dtDate  = DateAdd("s", -1, DateAdd("h", -1, Format(Time, "Long Time")))

Open in new window

or
dtDate  = DateAdd("s", -1, DateAdd("h", -1, strDate))

Open in new window

0
 
LVL 51

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
ID: 41863446
Hi,

pls try

dtDate = DateAdd("s", -3601, strDate)

Open in new window

3600s = 1h

Regards
0
 

Author Closing Comment

by:Kelvin4
ID: 41863459
Thanks to both. I should have used my head - twice!!
Kelvin
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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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