Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Date text Field

    I have an asp form that is submitted to sql server 2000. There are three
    date fields. How can I allow the user to enter the date without any
    seperators i.e. mmddyyyy, 07152004. I have seen forms on the web that
    allows you to do adding the - as you go. I have tried just entering
    07152004, but the sql server does not like this - type mismatch. The field
    is a datetime.

    Thanks!
    Darren


    Darren Woodbrey Guest

  2. Similar Questions and Discussions

    1. Changing to British date form a US style (text) field
      Hello all I have a document tracking database set up in FM Pro. One of the fields I use is a "Due Date" field which is scripted to add two days...
    2. Date comparison in a text data field
      I have a database column field defined as a text. I store dates in format: dd/mm/yyyy. The user passes a Start date search string in the same...
    3. Converting a text field to a date field - FM6
      I need to convert a Text field containing both auto and manually entered dates over to a Date field. The records that were autoentered move over...
    4. Linking date field to text field entry
      Is there a way to setup a date field that will automatically enter the date when any information is entered into a field next to it?
    5. date in text field
      How can I include a date that is formatted in the following structure 9-July-03, and include it in a form text field? The form input code is:...
  3. #2

    Default Re: Date text Field

    You'll have to deal with the user input if you want to give them freedom to
    enter dates at they like. Just be sure you deal with dates like 1/12/2004
    vs. 11/2/2004, and things like that.

    The format of the date when you insert it into SQL should ideally look like:

    2004-07-15

    So, it's just some string manipulation to take 07152004 and turn it into
    2004-07-15. If you're not sure how to go about that, post back.

    Ray at home

    "Darren Woodbrey" <darrenwoodbrey@hpfairfield.com> wrote in message
    news:O1TTWgqaEHA.1644@tk2msftngp13.phx.gbl...
    > I have an asp form that is submitted to sql server 2000. There are three
    > date fields. How can I allow the user to enter the date without any
    > seperators i.e. mmddyyyy, 07152004. I have seen forms on the web that
    > allows you to do adding the - as you go. I have tried just entering
    > 07152004, but the sql server does not like this - type mismatch. The
    field
    > is a datetime.
    >
    > Thanks!
    > Darren
    >
    >

    Ray at Guest

  4. #3

    Default Re: Date text Field

    > 2004-07-15

    That format is fine for Access. The only safe format for SQL Server is
    20040715 (which doesn't work in Access, unfortunately).

    Try this repro in SQL Server:


    SET LANGUAGE ENGLISH
    GO

    SELECT DATEADD(DAY, 1, '2004-07-05')
    GO
    SELECT DATEADD(DAY, 1, '2004-07-15')
    GO
    SELECT DATEADD(DAY, 1, '20040715')
    GO

    SET LANGUAGE FRENCH
    GO

    SELECT DATEADD(DAY, 1, '2004-07-05')
    GO
    SELECT DATEADD(DAY, 1, '2004-07-15')
    GO
    SELECT DATEADD(DAY, 1, '20040715')
    GO

    SET LANGUAGE ENGLISH



    Aaron [SQL Server MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139