Consulting

Results 1 to 11 of 11

Thread: ndate returning time in Holland not London

  1. #1
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location

    ndate returning time in Holland not London

    Hi all,

    I have a savedate function that works fine when run in London, howere returns a time when run in holland?? I am presuming it is a default format in excle rather than vba, but how do I change it please[
    HTML]Dim ndate As Date
    Dim savedate As Variant
    ndate = Range("cz2").Value
    savedate = Mid(ndate, 1, 2) & "_" & Mid(ndate, 4, 2) & "_" & Mid(ndate, 7, 4)[/HTML]

    field cz2 is populated as = 2017/05/08

    in London this returns ndate = 08/05/2017

    in holland this returns ndate = 12:00:00 AM

    Will log this on the excle as well just in case.

    Thanks in advance for any help

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try, formatted as required


    savedate = Format(DateValue(Range("CZ2")), "mm_dd_yyyy")
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    thanks, however
    savedate = Format(DateValue(Range("CZ2")), "mm_dd_yyyy")
    [/QUOTE]

    Tried and get the following compile error
    Wrong number of arguments or invalid property assignment

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try this
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    can't access due to security, can you break it down please

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Same as before + a button and a message box
    Option Explicit
    
    
    Private Sub CommandButton1_Click()
    Dim SaveDate
    SaveDate = Format(DateValue(Range("CZ2")), "mm_dd_yyyy")
    MsgBox SaveDate
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    still doesn't like the Format - as attached?????
    Attached Images Attached Images

  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Private Sub CommandButton1_Click() 
        msgbox Format([CZ2], "mm_dd_yyyy") 
    End Sub
    I think you better keep far from VBA or geography.

  9. #9
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    I think you better keep far from VBA or geography.
    , If only I could or we had any help to hand then I wouldn't have too..

  10. #10
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    there was a call function called Format, hence why it was failing if your interested.. lesson -> don't just use an old process without fully checking it

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    A useful lesson
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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