Results 1 to 4 of 4

Thread: Dates in Access SQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Dates in Access SQL

    For all you british people out there, or people who have dates in the following format
    dd/mm/yyyy

    How do you insert the date into sql. For example I have a combo box which gives the user a list of dates, I then want to look up a value from the databse depending on the specidied date. Curretly I am converting the date as follows

    VB Code:
    1. Function americanisedate(englishdate As Date) As String
    2.  
    3. americandate = Mid(englishdate, 4, 2) & "/" & Mid(englishdate, 1, 2) & "/" & Mid(englishdate, 7, 4)
    4.  
    5. americanisedate = americandate
    6.  
    7. End Function

    I just feel there must be a better way, as I understand dates are actually stotred in the database as number of seconds elapsed since 1900 (or some such).

    Anyway hope somebody understands what I'm waffling about and can help.

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Dates in Access SQL

    VB Code:
    1. Dim MyDate as Date
    2.  
    3. MyDate = Date()
    4.  
    5. MyDate = Format(MyDate,"dd/MM/YYYY")

    or thereabouts.

    HTH
    if you fail to plan, you plan to fail

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Dates in Access SQL

    Format(<date var>,"dd mmm yyyy") <--- Access useage
    Format(<date var>,"mm/dd/yyyy") <--- any sql useage (american formatting)
    Last edited by Ecniv; Apr 5th, 2005 at 11:01 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Re: Dates in Access SQL

    Thanks will give it a go.

    Still makes me cross, is mean the British don't have an empire anymore, and we now have to follow one of are ex colonies standards.

    Only jokes, without America we wouldn't have great TV shows like 24.

Posting Permissions

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



Click Here to Expand Forum to Full Width