Results 1 to 5 of 5

Thread: Get standard GMT time from the system using vba.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by LalitPandey87 View Post
    Thanks Rick this is exactly what i am looking for. Thanks again for your quick and great response.
    You are quite welcome. Believe it or not, this is old code I have had in my personal archives for I don't know how many years now (more than 6 for sure)... it is from my days back when I volunteered answering question for the old compiled version of VB (prior to doing so for Excel). Since it is just making Windows API function calls, no changes were needed before posting it to your message since VBA supports the same calls to the Window API functions.

  3. #3
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    14
    Below is the introduction by Chip to his program ---- This is a great tool if you have data coming from all over the world --- Maybe you got what you needed from Rick --- But this date bussiness is quite messy



    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
    ' modLocalTimeAndGMT
    ' By Chip Pearson, Excel Redirect, chip@cpearson.com
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
    ' This module contains functions to convert between Local Time and GMT (UTC) Time.
    ' These conversion functions take into account Daylight Savings Time. This module
    ' contains support functions for determining whether a date is within Daylight
    ' Savings Time.
    '
    ' The primary conversion functions are:
    ' -------------------------------------
    '
    ' ` Serial Times
    ' -------------------------
    ' GMTTimeToLocalTimeSerial
    ' This function converts a GMT (UTC) Time to the Local Time.
    ' Both input and output are VB/VBA Serial Dates.
    ' LocalTimeToGMTTimeSerial
    ' This function converts a local time to GMT (UTC) time.
    ' Both input and output are VB/VBA Serial Dates.
    '
    '
    ' FILETIMEs
    ' -------------------------
    ' FileTimeToSerialTime
    ' This converts a FILETIME to a serial time.
    ' SerialTimeToFileTime
    ' This function converts a serial time to a FILETIME.
    '
    ' SYSTEMTIMES
    ' -------------------------
    ' SystemTimeToSerialTime
    ' This function converts a SYSTEMTIME to a serial time.
    ' SerialTimeToSystemTime
    ' This function converts a serial time to a SYSTEMTIME.
    '
    '
    ' Current Local And GMT Times
    ' ----------------------------
    ' LocalTimeNowAsSerial
    ' Returns the current local date and time as a serial time. Same as Now().
    ' LocalTimeNowAsFILETIME
    ' Populates a FILETIME variable with the current local date and time.
    ' LocalTimeNowAsSYSTEMTIME
    ' Populates a SYSTEMTIME variable with the current local date and time.
    ' GMTNowAsSerial
    ' Returns the current GMT date and time as a serial time.
    ' GMTNowAsFILETIME
    ' Populates a FILETIME variable with the current GTM date and time.
    ' GMTNowAsSYSTEMTIME
    ' Populates a SYSTEMTIME variable with the current GMT date and tim.
    '
    '
    ' The supporting function to determine Daylight Savings Time are:
    ' ---------------------------------------------------------------
    '
    ' FirstDayOfWeekOfMonthAndYear
    ' This returns the first DayOfWeek for a date with the appropriate
    ' month and year. The Day component of the input value is not used,
    ' so it can be any day of the requested month and year.
    '
    ' IsDateWithinDST
    ' This function returns TRUE or FALSE indicating whether the specified
    ' date is within Daylight Savings Time.
    '
    ' LastDayOfWeekOfMonthAndYear
    ' This function returns the last DayOfWeek in the month and year of
    ' the specified DateValue The Day component of the input value is not used,
    ' so it can be any day of the requested month and year.
    '
    ' NthDayOfWeekInMonth
    ' This function returns date of the Nth occurance of DayOfWeek of the
    ' month and year of the input date value. The Day component of the input
    ' value is not used, so it can be any day of the requested month and year.
    '
    ' Daylight Savings Time is determined using USA standards and is assumed to start on
    ' either of the following dates:
    '
    ' For years prior to 2007, Daylight Savings Time starts on the first Sunday of April.
    ' Standard Time begins on the last Sunday of October.
    '
    ' For years 2007 and later, Daylight Savings Time begins on the second
    ' Sunday of March. Standard Time begins first Sunday of November.
    '
    ' NOTE: If you have the SYSTEMTIME and/or FILETIME and/or TIME_ZONE_INFORMATION
    ' declared Public elsewhere in your project, you should remove the declarations
    ' from this file.
    '
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
    xl2007 - Windows 7
    xl hates the 255 number

Similar Threads

  1. Inserting time in spreadsheet
    By papabill in forum Excel Help
    Replies: 17
    Last Post: 10-25-2013, 01:34 PM
  2. Calculate Time Difference Between Time In HH:MM
    By Stalker in forum Excel Help
    Replies: 8
    Last Post: 03-28-2013, 03:27 PM
  3. Get time difference in excel using vba
    By LalitPandey87 in forum Excel Help
    Replies: 1
    Last Post: 10-09-2012, 07:57 AM
  4. Displayin Date/Time in "original" time zone
    By Rasm in forum Excel Help
    Replies: 4
    Last Post: 04-21-2012, 02:02 AM
  5. Spreading a time range (shift time, etc) in columns.
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 1
    Last Post: 08-23-2011, 11:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •