=G_TIME(Origin, Destination, "Decimal") to return the time taken as a decimal. =G_TIME(Origin, Destination) to return the time taken in Excel time format (you’ll need to format the cell to make it display correctly). The syntax for using the function is as follows: I decided to give two options with this – to return it as decimal hours where 1 1/2 hours is represented as 1.5 hours, and to return it in Excel’s date format where 1 1/2 hours is shown as 01:30:00. The other main thing to handle is that the Google API returns the duration in seconds, which needs converting into a more useful format. That was easy enough to find out by referring to the XML schema for the Google Maps Directions API. The first one is to change "//leg/distance/value" to "//leg/duration/value". And it also turned out not to be too difficult, needing just a few changes to the function. This sounded like it might be a useful addition – you’d be able to work out things like average speed travelled. After a bit of back-and-forth by email with Google Translate as an intermediary (Gabriel is Brazilian and my live-in translator/interpreter/girlfriend is in Brazil too so she couldn’t help), I figured out that what Gabriel wanted was to return the time taken rather than the distance. I had a comment from Gabriel on the Google Distance post, asking if it could be adapted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |