none
Date Diff not working for UK? RRS feed

  • Question

  • I have a simple bit of code based on 3 text boxes.

    Box 1 TodaysDatetxt = Now()

    Box 2 VersionDatetxt  =3/1/2016 (date based on a date in a table that I can change manually for monthly expirations of the tool)

    Box 3 DateDifftxt= DateDiff("d"[VersionDatetxt].[TodaysDatetxt]

    On the Form Load of the Switchboard there is code that says:  

    If Me.DateDifftxt>31 Then

    DoCmd.Close

    DoCmd.OpenForm "OutOfDateFrm"

    ...and the user gets a message to go to a website and download the latest version and the website to paste into their browser.

    That's it, it's that simple.  I've had 2 people say that when they tried to load it, they got the expiration notice.  They should not be getting that because it doesn't expire for 20 days.

    The users that are getting the expiration notice are in the UK, could that make a difference.

    I don't know how it could, but maybe.

    Any help would be appreciated.


    Gee

    Monday, March 21, 2016 2:56 PM

Answers

  • Hi Gee. It could! VBA requires/expects dates in U.S. or ISO format. Check Allen Browne's website for explanation. To fix it, try using the Format() function. For example:

    DateDiff("d",Format([VersionDatetxt],"yyyy-mm-dd"),Format([TodaysDatetxt],"yyyy-mm-dd"))

    Hope that helps...

    • Marked as answer by GretaF Monday, March 21, 2016 5:27 PM
    Monday, March 21, 2016 3:10 PM

All replies

  • Hi Gee. It could! VBA requires/expects dates in U.S. or ISO format. Check Allen Browne's website for explanation. To fix it, try using the Format() function. For example:

    DateDiff("d",Format([VersionDatetxt],"yyyy-mm-dd"),Format([TodaysDatetxt],"yyyy-mm-dd"))

    Hope that helps...

    • Marked as answer by GretaF Monday, March 21, 2016 5:27 PM
    Monday, March 21, 2016 3:10 PM
  • How do I format the VerstionDatetxt?


    Gee


    • Edited by GretaF Monday, March 21, 2016 3:58 PM
    Monday, March 21, 2016 3:34 PM
  • How do I format the VerstionDatetxt?


    Gee



    Hi Gee. I tried to show it above. Did you try it? Just curious...
    Monday, March 21, 2016 4:18 PM
  • Yes and it did not work for them.

    It's hard to do this 'cause I don't have a way to test it very easily.

    I got the TodyasDatetxt to show the yyyy-mm-dd, but it threw off the VersionDatetxt and I'm trying to format the VersionDatetxt it match but I'm just getting it wrong.

    I tried on load:

    VersionDatetxt=Format(dd-mm-yyyy) 

    and that does not work.


    Gee

    Monday, March 21, 2016 4:23 PM
  • Hi Gee. Did you do exactly what I suggested? I gave you the code for the DateDiff() box. The format of the VersionDatetxt (what's showing on it) does not matter. It's the DateDiff() function we need to fix, which I tried to do earlier. I hope that makes sense...
    Monday, March 21, 2016 4:27 PM
  • I will try again...I appreciate your patience and help!


    Gee

    Monday, March 21, 2016 4:41 PM
  • No sweat. Here's the website with more information I was talking about.
    Monday, March 21, 2016 4:43 PM
  • It worked!!

    Oh, thank you so very much!

    the only thing I did differently was to format the other 2 fields to dd-mm-yyyy.


    Gee


    • Edited by GretaF Monday, March 21, 2016 5:28 PM
    Monday, March 21, 2016 5:27 PM
  • Hi Gee. Glad to hear you got it sorted out. Good luck with your project.
    Monday, March 21, 2016 5:31 PM