Results 1 to 6 of 6

Thread: Access - Managing foreign date format

  1. #1
    Join Date
    Dec 2009
    Posts
    192

    Access - Managing foreign date format

    Hello,
    In some countries, such date is 12.12.06 but in other countries it is like 12/12/2006. I did a feature on all my dates to settle the problem. This is a part of my code
    Public Function MyDate(atthe date As Date) As Date
    MyDate = Format(atthe date, "dd \ / mm \ / yy")
    End Function
    My concern is that in a SQL query in VBA which manages the date format, I do not always found a result for it.
    Here is the query:
    sSQL = "field SELECT FROM table" & _
    "WHERE ((productId =" & & LProduct ") AND (date <= #" & MyDate(dDateTR) & "#) AND (date2> = #" & MyDate(dDateTR) & "#)) ;"
    I am excepting an help from you guys.
    Last edited by Vodka; 14-01-2010 at 09:19 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    3,755

    Re: Access - Managing foreign date format

    Hello
    VBA is the date in the format of U.S.
    Month / day / year
    You will have to make a function to reverse the day and month. I do not think this is going to be too difficult. Just few lines of code can do the job. First try it, if you have problem in the code, then you can post back with it. Do not forget to post the code or the part of the code.

  3. #3
    Join Date
    Dec 2009
    Posts
    192

    Re: Access - Managing foreign date format

    Hello,
    I read it, but my date and date2 fields, it automatically start in U.S. format. I tried every thing I knew, but did not helped.
    Code:
    Public Function MyDate( date As Date) As Date
    Sun temp As Date
    temp = Month( date) & "/" Day &( date) & "/" & Year(date)
    MyDate = temp
    End Function
    Sun temp As Date
    temp = Month(date) & "/" Day &(date) & "/" & Year(date)
    MyDate = Format(temp, "dd \ / mm \ / yyyy")
    End Function

  4. #4
    Join Date
    Dec 2009
    Posts
    296

    Re: Access - Managing foreign date format

    Hi,
    Even i have this problem. I have tried some combination see if these are correct.
    Hello,
    Even I have tried these
    Public Function MyDate(date As Date) As Date
    Sun temp As Date
    temp = DateSerial(Year(date), Month(date), Day(date))
    MyDate = Format(temp, "dd \ / mm \ / yyyy")
    End Function
    And this
    Public Function MyDate(date As Date) As Date
    Sun temp As Date
    temp = DateSerial(Year(date), Month(date), Day( date))
    MyDate = temp
    End Function

  5. #5
    Join Date
    Dec 2009
    Posts
    192

    Re: Access - Managing foreign date format

    Hello,
    I add that when I'm with the other countries format , yet there did not reverse with the month, whereas with the points it does not pass. The only difference is how it works or not is the / or points. So I think it automatically manages the U.S. format that is the default format of the date. Is there any easy way to change the format of the date. I think there should be one, because this is not going very flexible.

  6. #6
    Join Date
    Jan 2008
    Posts
    3,755

    Re: Access - Managing foreign date format

    Hello,
    Write mixed in an modulates this function:
    DATEUS Function (ByVal dt As Variant)
    If IsNull (dt) Then Exit Function
    DATEUS = "#" & Month (dt) & "/" & Day (dt) & "/" & Year (dt) & "#"
    End Function
    Whenever you want to use a date in other countries format in vba you apply this.

Similar Threads

  1. Replies: 8
    Last Post: 09-01-2012, 09:41 PM
  2. Replies: 3
    Last Post: 11-12-2010, 11:45 PM
  3. Using date format in JSP
    By KAMANA in forum Software Development
    Replies: 6
    Last Post: 29-07-2010, 10:32 AM
  4. Managing the access control in database
    By Carnie in forum Software Development
    Replies: 4
    Last Post: 19-02-2010, 10:03 PM
  5. Replies: 0
    Last Post: 13-10-2008, 04:35 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
  •  
Page generated in 1,711,645,357.13009 seconds with 17 queries