title: Adjsut the unix timestamp to be the same on Yahoo Finance
body: <p>In Sheet1, I have ticker in B1 (say "AA") and start date in B2 (say 21/4/2009) and the end date in B3 (say 23/4/2009)</p>
  
  <p>When navigating manually to the desired url I got the link like that
  <a href="https://finance.yahoo.com/quote/AA/history?period1=1240290000&amp;period2=1240462800&amp;interval=1d&amp;filter=history&amp;frequency=1d" rel="nofollow noreferrer">https://finance.yahoo.com/quote/AA/history?period1=1240290000&amp;period2=1240462800&amp;interval=1d&amp;filter=history&amp;frequency=1d</a></p>
  
  <p>But when using the code so as to construct the link I got little different UNIX timestamp like this
  <a href="https://finance.yahoo.com/quote/AA/history?period1=1240272000&amp;period2=1240444800&amp;interval=1d&amp;filter=history&amp;frequency=1d" rel="nofollow noreferrer">https://finance.yahoo.com/quote/AA/history?period1=1240272000&amp;period2=1240444800&amp;interval=1d&amp;filter=history&amp;frequency=1d</a></p>
  
  <p>Notice period1 for example in both links
  How can I adjust the code so as to be the same as the link at yahoo?</p>
  
  <p>I tried something like that</p>
  
  <pre><code>period1 = ToUnix(.Range("B2").Value &amp; " 05:00:00")
  </code></pre>
  
  <p>This solved the problem of those dates but doesn't solve other and different dates so my logic is not correct</p>
  
  <p>Here's the code I tried</p>
  
  <pre><code>Sub Yahoo_Finance()
  Dim ws          As Worksheet
  Dim sURL        As String
  Dim sTicker     As String
  Dim period1     As Long
  Dim period2     As Long
  Dim r           As Long
  
  Set ws = ThisWorkbook.Worksheets("Sheet1")
  r = 6
  
  With CreateObject("MSXML2.ServerXMLHTTP")
      With ws
          sTicker = .Range("B1").Value
          period1 = ToUnix(.Range("B2").Value &amp; " 05:00:00")
          period2 = ToUnix(.Range("B3").Value &amp; " 05:00:00")
      End With
  
      sURL = "https://finance.yahoo.com/quote/" &amp; sTicker &amp; "/history?period1=" &amp; period1 &amp; "&amp;period2=" &amp; period2 &amp; "&amp;interval=1d&amp;filter=history&amp;frequency=1d"
  
      Debug.Print sURL
  End With
  End Sub
  
  Public Function ToUnix(dt) As Long
  ToUnix = DateDiff("s", "1/1/1970", dt)
  End Function
  </code></pre>