General discussion

  • Creator
    Topic
  • #2073583

    What’s the correct way to store a date??

    Locked

    by webmaster ·

    I’m using a

    to ask the user for a date. Like so…
    ” METHOD=”GET”>
    Date:

    Then i’m storing the date…
    strIBUSKEY = “‘” & Trim(Request.QueryString(“ibuskey”)) & “‘, ”

    When i attempt to write the above string into a record’s date-field i get an error that i’m trying to write a string of text into a date-field.
    Now, i’m new to VBScript (which is what i’m using to write my ASP’s). So, obviously, i’m storing the date in an inappropriate variable type.

    How should i be storing this date info?

    [email protected]

All Comments

  • Author
    Replies
    • #3894694

      What’s the correct way to store a date??

      by mukul_gandhi ·

      In reply to What’s the correct way to store a date??

      You have to read date in asp as –
      strIBUSKEY = Request.QueryString(“ibuskey”)
      But u must make sure that date value is entered in html form in correct format. Input format of date will depend on the database ur using. e.g in Oracle, u must enter date by default as DD-MON-YYYY. If u choose some other input format, u have to convert the date input in asp appropriately e.g using to_date function in Oracle. You must give instruction in HTML page for the format u want in input.
      Details for other databases are different. Check with them individually.

      regards
      -mukul

    • #3776456

      What’s the correct way to store a date??

      by shadowtraitor ·

      In reply to What’s the correct way to store a date??

      hey
      You should tell the users the format you want or gather the date string from seprate input boxes such a select combo box for the month, and 2 input boxes for the year and date.
      Once you have the datestring you can convert it to be of datetime format using the Vbscript function call as follows
      datestring = cdate(datestring)
      in you SQL statement ensure that the you enclose the datestring with two pound signs(#) as in sample below
      SQLSTRING = “INSERT INTO Timesheet (Date)values (“& datestring & “#)”
      if you goto http://www.itknowledge.com you will find some good books on ASP and VB script.

      Hope I helped

Viewing 1 reply thread