Solved

Entering Greenwich time into a cell directly, possibly from some web site

Posted on 2014-03-25
8
149 Views
Last Modified: 2014-03-26
Hello,
I searched the MS Excel site; http://office.microsoft.com/en-us/excel-help/excel-functions-by-category-HP005204211.aspx for a function that would give me the current Greenwich time, which I could use in a cell.
I found this =A2+1-TIME(6,0,0), which I could work with, but I am hoping for some function like; =TIME(Greenwich).  Then I could convert this time to any other time zone.
Comments?
0
Comment
Question by:chima
  • 4
  • 2
  • 2
8 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 39954492
You'll get the full lowdown on it on Chip Pearson's page: http://www.cpearson.com/excel/LocalAndGMTTimes.htm

Unless you're ready to go with Windows API and user-defined functions, there is no straight solution for you, but you could set defined names to accomplish something similar, e.g. set Greenwich as a defined name =6/24, assuming you're six hours west from GMT, and then you can use it in a formula like

=now()+Greenwich
0
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 150 total points
ID: 39954515
Try this from http://www.myengineeringworld.net/2013/09/retrieve-time-from-internet-server-vba.html
Option Explicit

Function InternetTime(Optional GMTDifference As Integer) As Date

    '-----------------------------------------------------------------------------------
    'This function returns the Greenwich Mean Time retrieved from an internet server.
    'You can use the optional argument GMTDifference in order to add (or subtract)
    'an hour from the GMT time. For Example if you call the function as:
    '=InternetTIme(2) it will return the (local) hour GMT + 2. Note that the
    'GMTDifference variable is an integer number.
   
    'Written by:    Christos Samaras
    'Date:          25/09/2013
    'Last Updated:  20/11/2013
    'e-mail:        xristos.samaras@gmail.com
    'site:          http://www.myengineeringworld.net
    '-------------------------------------------------------------------------------

    'Declaring the necessary variables.
    Dim Request     As Object
    Dim ServerURL   As String
    Dim Results     As String
    Dim NetDate     As String
    Dim NetTime     As Date
    Dim LocalDate   As Date
    Dim LocalTime   As Date
   
    'Check if the time difference is within the accepted range.
    If GMTDifference < -12 Or GMTDifference > 14 Then
        Exit Function
    End If

    'The server address.
    ServerURL = "http://www.timeanddate.com/worldclock/fullscreen.html?n=2"
   
    'Build the XMLHTTP object and check if was created successfully.
    On Error Resume Next
    Set Request = CreateObject("Microsoft.XMLHTTP")
    If Err.Number <> 0 Then
        Exit Function
    End If
    On Error GoTo 0
   
    'Create the request.
    Request.Open "GET", ServerURL, False, "", ""
   
    'Send the request to the internet server.
    Request.Send
   
    'Based on the status node result, proceed accordingly.
    If Request.ReadyState = 4 Then
       
        'If the request succeed, the following line will return
        'something like this: Mon, 30 Sep 2013 18:33:23 GMT.
        Results = Request.getResponseHeader("date")
       
        'Use the Mid function to get something like: 30 Sep 2013 18:33:23.
        Results = Mid(Results, 6, Len(Results) - 9)
       
        'Use the Left and Right function to distinguish the date and time.
        NetDate = Left(Results, Len(Results) - 9) '30 Sep 2013
        NetTime = Right(Results, 8) '18:33:23
       
        'Convert the date into a valid Excel date 30 Sep 2013 -> 30/9/2013.
        'Required for countries that have some non-Latin characters at their alphabet (Greece, Russia, Serbia etc.).
        LocalDate = ConvertDate(NetDate)

        'Add the hour difference to the retrieved GMT time.
        LocalTime = NetTime + GMTDifference / 24

        'Return the local date and time.
        InternetTime = LocalDate + LocalTime
   
    End If
   
    'Release the XMLHTTP object.
    Set Request = Nothing

End Function

Function ConvertDate(strDate As String) As Date

    '-------------------------------------------------------------------------
    'This function converts the input date into a valid Excel date.
    'For example the 30 Sep 2013 becomes 30/9/2013.
    'Required for countries that have non-Latin characters at their alphabet.

    'Written by:    Christos Samaras
    'Date:          25/09/2013
    'e-mail:        xristos.samaras@gmail.com
    'site:          http://www.myengineeringworld.net
    '-------------------------------------------------------------------------

    'Declaring the necessary variables.
    Dim MyMonth As Integer

    'Check the month and convert it to number.
    Select Case UCase(Mid(strDate, 4, 3))
        Case "JAN": MyMonth = 1
        Case "FEB": MyMonth = 2
        Case "MAR": MyMonth = 3
        Case "APR": MyMonth = 4
        Case "MAY": MyMonth = 5
        Case "JUN": MyMonth = 6
        Case "JUL": MyMonth = 7
        Case "AUG": MyMonth = 8
        Case "SEP": MyMonth = 9
        Case "OCT": MyMonth = 10
        Case "NOV": MyMonth = 11
        Case "DEC": MyMonth = 12
    End Select

    'Rebuild the date.
    ConvertDate = DateValue(Left(strDate, 2) & "/" & MyMonth & "/" & Right(strDate, 4))

End Function

Open in new window


The InternetTime function will return GMT.
0
 

Author Comment

by:chima
ID: 39954558
nutsch, thanks, that work for me.  Now how could I "refresh" the excel sheet?  Is there a keyboard key like F5 to refresh the functions used, like =now() ?
I set the cell format to hh:mm:ss and used =now()+TIME(6,0,0) to convert it to Greenwich time.
Now I need a way to easily refresh the formula, to update it.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:chima
ID: 39954561
MicroShadow, I'll keep it in mind, thanks
0
 

Author Comment

by:chima
ID: 39954590
nutsch, F9 seems to do the trick.
0
 
LVL 39

Accepted Solution

by:
nutsch earned 350 total points
ID: 39954610
Indeed, F9 is the Calculate Now shortcut.
0
 

Author Closing Comment

by:chima
ID: 39956852
macroShadow, your answer was great.  I needed a simple solution.  Thank you both.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39957148
No problem, we're here for you're benefit...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

821 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