473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

timezone from lat/longitude

1,271 Expert 1GB
I'm trying to find a way to calculate a timezone from latitude and longitude. Anybody out there doing that in VBA?

Thanks,
Jim
Jun 9 '14 #1

✓ answered by twinnyfo

jimatqsi,

Not sure if this would helphttps://developers.google.com/maps/d...tion/timezone/. It is a Google API, and if you don't mind popping up a web browser with your VBA, it might be helpful. My thought is that without an extensive DB of all time zones, we are relegated to using some tools that already exist, but in a different format. Let us know if you come up with anything.

3 2276
twinnyfo
3,653 Expert Mod 2GB
jimatqsi,

Not sure if this would helphttps://developers.google.com/maps/d...tion/timezone/. It is a Google API, and if you don't mind popping up a web browser with your VBA, it might be helpful. My thought is that without an extensive DB of all time zones, we are relegated to using some tools that already exist, but in a different format. Let us know if you come up with anything.
Jun 9 '14 #2
jimatqsi
1,271 Expert 1GB
Thanks. Google's the same place I ended up. Should work fine for this app, it's a great service. Here's the code. Doesn't really bring up a browser, it issues a service call and receives a reply within the vba.
Expand|Select|Wrap|Line Numbers
  1.     Dim tzName As String
  2.     Dim strSQL As String
  3.     Dim dbs As DAO.Database
  4.     Dim rs1 As DAO.Recordset
  5.     Dim apikey As String
  6.     Dim byteData() As Byte
  7.     Dim XMLHTTP As Object
  8.     Dim TimeZoneID As Long
  9.     Dim GoogleReply As String
  10.  
  11. Set dbs = CurrentDb
  12.  
  13.     url = "https://maps.googleapis.com/maps/api/timezone/xml?location=\lat\,\long\&timestamp=\timestamp\&key=\apikey\"
  14.     apikey = "my apikey"
  15.  
  16.     url = Replace(url, "\lat\", Latitude)
  17.     url = Replace(url, "\long\", Longitude)
  18.     url = Replace(url, "\timestamp\", 0)   ' don't need to know what time it is
  19.     url = Replace(url, "\apikey\", apikey)
  20.  
  21.     Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
  22.  
  23.     XMLHTTP.Open "GET", url, False
  24.  
  25.     XMLHTTP.send
  26.     byteData = XMLHTTP.responseBody
  27.     GoogleReply = StrConv(byteData, vbUnicode)
  28.     Set XMLHTTP = Nothing
  29.  
Thanks again.
Jun 9 '14 #3
twinnyfo
3,653 Expert Mod 2GB
That's actually pretty cool. If similar code works for addresses, that could find some applications in sales....

Thanks for sharing!
Jun 9 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jason Kinkade | last post by:
I recently installed MySQL 4.0.18 on my slackware 9.1 machine (kernel 2.4.25) by compiling the source. It works fine, and all tests pass except one. The timezone test. Can someone tell me why...
7
by: Jim Davis | last post by:
I'm (still) working on an ISO 8601 date parser. I want to convert at least the formats described here: http://www.w3.org/TR/NOTE-datetime Well.. I've got most of it working (via RegEx's) good...
1
by: cnliou | last post by:
Hi! If I correctly understand v7.4 manual, value, say, '2003-11-26 12:00' in TIMESTAMP WITHOUT TIMEZONE column should output '2003-11-26 19:00' for "+08:00" timezone. The following test...
4
by: YS Sze | last post by:
If you know the exact longitude and latitude for a specific location, would anyone think it'd make any sense to find out if this set of location numbers is really part of the Fibonacci series or...
2
by: David Garamond | last post by:
When a timestamp string input contains a timezone abbreviation (CDT, PST, etc), which timezone offset is used? The input date's or today date's? The result on my computer suggests the latter. #...
13
by: Bruno Wolff III | last post by:
Recently there has been some discussion about attaching a timezone to a timestamp and some other discussion about including a 'day' part in the interval type. These two features impact each other,...
3
by: asanford | last post by:
I want to create a web service that allows the caller to pass a DateTime to the web service (that is, create a web method such as void MyWebMethod(DateTime dt).) However, I want to be able to...
1
by: Abdullah Kamran | last post by:
I have found a method to find the timezone using longitude of a place from somewhere. I tried it to do some calculations and found it working, it is not very accurate though (needs some improvements)...
2
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the...
5
by: arial | last post by:
Hi all, I have a sql .bak file which i need to convert into xml file. can someone help with this? pointing out to some tutorial or some suggetion on how to start? Thak you,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.