+ Reply to Thread
Results 1 to 18 of 18

StaticDate() Function shows year as 2014?

  1. #1
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    StaticDate() Function shows year as 2014?

    Hi All -

    I was looking through past posts for an easy way to do a date stamp. I found a post with the following function recommendation -

    Please Login or Register  to view this content.

    It works great! But the year is coming up as 2014 when I use StaticDate(). The date is correct when I try Now() and Today() functions. I'm using Excel 2004 (Mac).

    Any ideas? Thanks!
    Last edited by Samba1; 06-07-2010 at 07:30 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    On the Mac you're running 1904 date system rather than the "standard" PC 1900 date system - ie day 0 is 1 Jan 1904 rather than than 0 Jan 1900.

    It would seem that the datetime functions in VBA utilise the 1900 date system irrespective of the workbook settings - hence the serial returned is 1900 based and once converted on the worksheet it is 4 years and 1 day greater than expected.

    You could try:

    Please Login or Register  to view this content.
    though there are undoubtedly better methods I can't think of...

  3. #3
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Re: StaticDate() Function shows year as 2014?

    Thanks DonkeyOte - But if I use that code then the date/time is updated instead of fixed. Is there an easy way to just subtract the 4 years in another cell? I know I can subtract 1,460 days from the cell that contains the date/time, but can I focus on the year instead of the total days?

    Thanks!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    Quote Originally Posted by Samba1 View Post
    Thanks DonkeyOte - But if I use that code then the date/time is updated instead of fixed.
    No, it is not - the function is evaluated in memory and returned as a value (the volatile call is not embedded into the parent cell in any way).

  5. #5
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Re: StaticDate() Function shows year as 2014?

    Quote Originally Posted by DonkeyOte View Post
    No, it is not - the function is evaluated in memory and returned as a value (the volatile call is not embedded into the parent cell in any way).
    Well...when I use that code, the time (and most likely the date) is updated when I go to close the workbook, then asks if I want to save....

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    The first time you enter the function will calculate and thus you will be asked to save, thereafter opening and subsequently closing will not invoke a calculation.

    The non-volatility can be proven by pressing F9 - you will note the time stamp does not alter as it would were it Volatile (ie were =NOW() in the cell)

    If you are still receiving save prompts then that implies you have other volatiles in place within your file.

    (edit: you may also be running on Manual mode with Calc before Save activated which is causing other cells to alter)
    Last edited by DonkeyOte; 06-07-2010 at 05:54 PM.

  7. #7
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Re: StaticDate() Function shows year as 2014?

    Ugh - I feel like I'm missing something stupid. The time stamp updates as soon as the book opens. I'm a rookie at VBA, so let me list the basics to make sure we're on the same page -

    I have one other Volatile functions in another sheet that's used for a project timeline.
    The Calculation option is set to Automatic with "before save" checked.
    For right now, the function in the test cell is just "=staticdate()"
    I have the following code in a module -
    Please Login or Register  to view this content.
    Thanks for your patience!

  8. #8
    Registered User
    Join Date
    10-28-2009
    Location
    California, USA
    MS-Off Ver
    Excel 2011 (Mac)
    Posts
    39

    Re: StaticDate() Function shows year as 2014?

    DonkeyOte -

    I found an option that allows me to switch the date system from 1904 (Mac) to 1900 (Windows) as you referred to earlier. This allows me to use the original function and have the right date. Guess I was missing something stupid!

    Thank you for the help!

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    I'm glad you have resolved to your satisfaction - just for clarity:

    Quote Originally Posted by Samba1
    I have one other Volatile functions in another sheet that's used for a project timeline.
    A file with any Volatiles present (with XL in Auto Calc. mode) will always generate a Save prompt given the Volatile function(s) will recalculate upon workbook being opened.

    Quote Originally Posted by Samba1
    The time stamp updates as soon as the book opens.
    I don't have a Mac so I can't replicate, all I can say (categorically) is that the same does not occur on a PC - ie the UDF is not volatile and will only recalculate via a Full recalc (CTRL + SHIFT + F9) or if the formula is itself is re-entered.

    (edit: invoking a Calc upon open via the Open Event would also cause the UDF to recalculate of course)
    Last edited by DonkeyOte; 06-08-2010 at 02:17 AM.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: StaticDate() Function shows year as 2014?

    I can confirm the recalc on opening in XL2004 - it happens with or without the Evaluate.
    Everyone who confuses correlation and causation ends up dead.

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    Thanks for testing R.

    Is this VB5/VB6 related you think or the result of something else ?

    (reminds me somewhat of the SUMIF discrepancies discovered previously)

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: StaticDate() Function shows year as 2014?

    Honestly, I can't say. I don't have 97 anywhere to test on anymore so I don't know if the same occurred there (I've never heard of it if it did, though) or if it is Mac specific. I'll see if I can find out.
    Last edited by romperstomper; 06-08-2010 at 08:00 AM.

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    thanks... and just to clarify for my own sanity - we're saying that on the Mac all UDFs are in essence at least semi-volatile ? (ie on open)
    (volatile where specified)

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: StaticDate() Function shows year as 2014?

    It would appear so. A straight recalc (with Cmd+=) has no effect.

  15. #15
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    Thanks - figured I was pop an email off to the man at DecisionModels to see if he knows anything of this behaviour.

    D.O.

  16. #16
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    R, CW came back with below suggestion (for testing if nothing else as he like me is Mac-less)

    Quote Originally Posted by CW
    Might be worth to try switching off refresh of External Links and see if that changes the behaviour.
    Cheers,
    D.O.

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: StaticDate() Function shows year as 2014?

    Not sure what he means by that. There are no links, so the Edit -Links option is unavailable, and the only other one is the 'ask to update automatic links' which is already on.

  18. #18
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: StaticDate() Function shows year as 2014?

    OK thanks - I will post something up in the place that can not be mentioned to see if others can verify the same on older versions etc...

    Thanks R.
    D.O.
    Last edited by DonkeyOte; 06-08-2010 at 12:54 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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