+ Reply to Thread
Results 1 to 3 of 3

UnixToDTM conversion function needed

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    BionicRooster
    MS-Off Ver
    BionicRooster
    Posts
    2

    UnixToDTM conversion function needed

    I am trying to get a function to convert Unix time to Excel date time. I need to be able to enter =UnixToDTM(A1) to get the Excel date/time value of the Unix date that is stored in cell A1.
    I have the formula that works but I do not want to enter it every time I need to do this conversion. The working formula is:
    =(((A1/60)/60)/24)+DATE(1970,1,1)+(-5/24)
    the -5/24 adjusts for timezone.

    I tried this code but all I get is a #name? error:

    Public Function UnixToDTM(ByVal sUNIX As Long) As Double
    Dim sValue As Double
    sValue = (sUNIX / 86400) + 25569 + (-5 / 24)
    UnixToDTM = sValue
    End Function

    I have never done a function before and am stuck on this one. Any help is appreciated.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: UnixToDTM conversion function needed

    Here's one from John McGimpsey's site:

    http://www.mcgimpsey.com/excel/udfs/unixtoxltime.html

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    09-10-2012
    Location
    BionicRooster
    MS-Off Ver
    BionicRooster
    Posts
    2

    Re: UnixToDTM conversion function needed

    Thanks Pete. That solved the problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. needed macro for conversion
    By baluvasa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2013, 02:00 AM
  2. [SOLVED] Help Needed on a date conversion
    By barron2245 in forum Excel General
    Replies: 9
    Last Post: 11-17-2012, 11:51 AM
  3. [SOLVED] Can I program this needed format conversion AFTER pivot table
    By Todd F. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-31-2006, 11:00 AM
  4. Much help needed on conversion!
    By oOpsy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-29-2005, 01:04 PM
  5. conversion needed
    By juster21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1