Results 1 to 4 of 4

Thread: help adding date to sql server

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    London
    Posts
    11
    Hi,

    I'm trying to add a date (user specified) to my SQL server using an ASP page with drop down menus to select day, month and a text with 2 characters for year.
    Then I have a string to put them together as one variable and I am trying to use the function fromatdatetime to get the date into a valid format for the db (using datetime datatype).
    My problem lies in how to split up the date terms. If i use forward slash it divides the numbers and if i use colons or full stops it displays as time.
    I've seen this method of collecting date info millions of times on other web pages but I can't get it to work.

    my code:

    dim start
    dim startd
    start = Request.Form ("startd") & "." & Request.Form ("startm") & "." & Request.Form ("starty")
    startd = FormatDateTime(start,3)

    where startd is an optionbox for day, startm an option for month and starty a 2 character textbox for year.

    Thanks for any advice

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    London
    Posts
    11
    I've also tried stuff with single quotes ie:

    start = "'" & Request.Form ("startd") & "." & Request.Form ("startm") & "." & Request.Form ("starty") & "'"

    didn't work like this, with or without the formatdatetime function.

    any other ideas?

  3. #3
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    Have you tried...
    Code:
    StartDate = Request("startd") & "/" & Request("startm") & "/" & Request("starty")
    ??????

    PS: the .form dont matter, I was just lazy

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    London
    Posts
    11
    yeah I tried that but the "/" character meant that the numeric values entered for the dates all divided themselves into each other.
    I have fixed it now by using ascii code to represent the "/" ie:
    startdate = Request.Form ("startm") & chr(47) & Request.Form ("startd") & chr(47) & Request.Form ("starty")
    This works but is a bit of a work round rather than pure solution.
    Thanks for your input though,
    George

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