Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Sep 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql and dates (2002)

    Hi all,
    i know this must sound stupid. im trying to run an sql line in code. im putting a date in the sql string.
    the date is formatted dd/mm/yyyy just like the field its corresponding to.
    This is the end of the string

    ((tblSection6.Period)=" & "#" & Format(PDate, "dd/mm/yyyy") & "#" & "));"

    doesnt seem to like it. anyone help me out?
    it just returns no recs when i know there are some there

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: sql and dates (2002)

    I believe that dates must be in format mm/dd/yy if you are going to embed them (that is, surround them with #...#). Not 100% sure on this, though.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: sql and dates (2002)

    Mark is correct, dates MUST be in US date format in SQL, i.e. mm/dd/yy or mm/dd/yyy.

    By the way, you can simplify the expression to

    ... tblSection6.Period = #" & Format(PDate, " mm/dd/yyyy") & "#)"

Posting Permissions

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