1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Search DB with date

Discussion in 'C#' started by pero2000, Feb 10, 2006.

  1. #1
    Hi to all. This q is probably sily for most of you, but for me...
    How to convert numbes from 3 dropdown lists into a date ? On a page there are a 3 dropdown lists where user can select day, month and year.
    Then it should search a database is the date (entered in the dropdown's) greater/smaller/etc. from the date in the database. How to do this ?
    Thank you
    SEMrush
     
    pero2000, Feb 10, 2006 IP
    SEMrush
  2. YIAM

    YIAM Notable Member

    Messages:
    2,486
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #2
    Late the three fields are: mm,dd,yy
    
    dt=Request.Form("mm")& "/" &Request.Form("dd")& "/" &Request.Form("yy")
    
    Code (markup):
    SQL Statement should be like this

    strSQL = "SELECT table.* FROM table where date= # " & dt & " # "
    Code (markup):
    Say small thanks if the code is correct:)
     
    YIAM, Feb 10, 2006 IP
  3. kjewat

    kjewat Active Member

    Messages:
    149
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi.

    Are you asking for the SQL or the entire process of connecting to the database and execute the query?

    The SQL should be simple. I assume you are using mysql...

    Just create a string on the form 'YYYY-MM-DD' from the drop down boxes. Then the SQL should be something like (for a greater than search)
    SELECT * FROM table_name WHERE column_name > 'YYYY-MM-DD'
    Code (markup):
    Similar for less than (<) and equal (=).

    This link will give you more details about dates in mysql.
     
    kjewat, Feb 10, 2006 IP
  4. chippi

    chippi Peon

    Messages:
    194
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It depends on which database software you use. Date fields rules are different on different databases softwares even same software's different solutions. But as a general rule these kind of code help you.

    NewDATE=CDATE(request.form("month")&"."&request.form("day")&"."&request.form("year"))

    You can have to change &"."& to &"/"& according your database software. Please tyr it again.
     
    chippi, Feb 10, 2006 IP