Results 1 to 2 of 2

Thread: WHERE in SQL

  1. #1
    Join Date
    Apr 2013
    Posts
    17

    Unanswered: WHERE in SQL

    I want to find field "id_zlecenia" - autonumber where field "DataPrzyjecia" - Date is youngest in table "tblZlecenia", I have a problem with WHERE, I know that, should use "#" for a date field, but I don't know how to write it.
    Function - I think MAX will be ok.,

    Code:
    Dim sSQL As String
    Dim rst As Recordset
    sSQL = "SELECT id_zlecenia FROM tblZlecenia WHERE... "
    Set rst = CurrentDb.OpenRecordset(sSQL)
    Me.Tekst1 = rst!ID_Zlecenia
    
    
    rst.Close: Set rst = Nothing

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not sure to understand what you mean with Date is youngest in table "tblZlecenia"
    If DataPrzyjecia is of type Date/Time and if you want to retrieve the most recent date in this column, you can use (provided that no dates are in the future):
    Code:
    SELECT MAX(DataPrzyjecia) FROM tblZlecenia;
    Have a nice day!

Posting Permissions

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