Results 1 to 4 of 4

Short Date Not Playing

  1. #1
    Join Date
    Apr 2010
    Posts
    19

    Short Date Not Playing

    Its been a few years since I needed to do anything on the application I made for work...But then clients ask for new stuff occasionally and this is proving more of a challenge than I thought it would.



    Simply put I have to code dates according to day of the week and apply a different code for public holidays. Its the last that is proving interesting to say the least.

    I have a table set up with two fields Name of Holiday and Date of Holiday. The date is formatted short date.

    I am using an SQL statement to check a date input on a form against the dates in the table:

    Code:
     strSQL = "SELECT tblCode.PublicHoliday, tblCode.HolidayDate " & _
                     "FROM tblCode " & _
                     "WHERE tblCode.HolidayDate = #" & Format(Me.txtDt, ShortDate) & "#"
    The immediate window shows this is producing the following SQL which reads correctly:

    Code:
    SELECT tblCode.PublicHoliday, tblCode.HolidayDate FROM tblCode WHERE tblCode.HolidayDate = #3/06/2019#
    However when I run the code it produces wrong result being coded as any other day not a public holiday.

    When I copy and paste the SQL statement from the immediate window into a query then view the query in design view I see the date format has been changed to American date format being 6/3/19 rather than our date format being 3/6/19. Interesting this doesn't produce an error on 19/4/19 it codes correctly.

    The computer region is set to Australia, the languages are set to Australia, the short date format is stipulated at table, at form and in query. What am I missing or is there a better way to write this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,003
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    Join Date
    Apr 2010
    Posts
    19
    Quote Originally Posted by pbaldy View Post
    Thanks That's all I needed

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,003
    Happy to help!
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Convert date from short date to general date
    By cebrower in forum Access
    Replies: 4
    Last Post: 04-24-2019, 08:08 AM
  2. Replies: 2
    Last Post: 10-30-2017, 02:33 PM
  3. Windows 10 and short date format.
    By NorwegianSiggy in forum Access
    Replies: 1
    Last Post: 09-04-2015, 01:34 PM
  4. How to add Short Date to Field
    By nono5551212 in forum Access
    Replies: 2
    Last Post: 06-06-2014, 10:55 PM
  5. Short date comparison
    By andy101 in forum Programming
    Replies: 2
    Last Post: 03-17-2011, 04:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums