Date format change not working

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

  1. #1

    Default Date format change not working

    Im trying to change the date format entered into a textbox from dd/mm/yy to yyyy/mm/dd so as my stored procedure is run correclty. The date is entered in a textbox called date. I attemped to use the line:

    newdate = year(lsDate) & "/" & month(lsDate) & "/" & Day(lsDate

    in order to change the date format in the background, but it hasn't seemed to have worked. Can anyone show me where I've went wrong. Thank you very much for any help anyone is able to give me

    <
    lsDate = Request.Form("date"
    newdate = year(lsDate) & "/" & month(lsDate) & "/" & Day(lsDate
    set dbconn = server.CreateObject("ADODB.Connection"
    set lrstLog = server.CreateObject("ADODB.Recordset"

    dbConn.Open Application("connectionString"
    'dbconn.Open "DSN=WEBaccounts;uid=patrice;pwd=gillan;PageTimeou t =5;
    'dbconn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=;Initial Catalog=cms_out;Data Source=sunaccserv

    lrstLog.Open "ByWeekEnding '" & newdate & "'", dbconn,

    %>
    Sean Guest

  2. Similar Questions and Discussions

    1. Date Format in Com+
      Hi All, I have one Component in VB6. My component receive a date as string parameter ("dd/MM/yyyy"). My componente understand "MM/dd/yyyy". Then I...
    2. date format change from YYYYMMDD?
      We are in the process of migrating our database server over to a new system. The old system has Coldfusion 4.5, Win2k Server and MS SQL 2000. We're...
    3. Change Date Format
      I have a date being entered into a textbox in a dd/mm/yy format, however I need to be able to change this format to a yyyy/mm/dd in order to pass the...
    4. converting date into database date format(newbie)
      Hi! U can convert "8-Aug-03" into mysql date which requires yyyy-mm-dd format as below. <?php date("Y-m-d",strtotime("8-Aug-03")); ?>
    5. Nautulus: time/date format change ?
      I run RH9 with Gnome / Nautilus. I am irritated by the time/date format in Nautilus. like : " Wednesday, July 9 2003 at 10:44:14 PM " ! Does...
  3. #2

    Default Re: Date format change not working

    For one, it would help if we had any clue what you mean by "doesn't seem to
    have worked." Do you get an incorrect date? Do you get an error message?
    If so, what is it?

    Second, VBScript on your machine is very unlikely to understand dd/mm/yyyy
    as the date you expect it to. So instead of using year/month/day functions,
    parse it as a string (use split against "/" to break it into parts, then
    reformat appropriately).

    SQL Server isn't going to understand the date format 2004/4/9. Use YYYYMMDD
    (no slashes). You need to pad the month and day with leading zeros. See
    [url]http://www.aspfaq.com/2300[/url] for a helper function to pad digits...

    Anyway, one suggestion would be to use dropdowns for month, day and year.
    This practically eliminates validation, avoids any ambiguity, and allows you
    to completely control the format of the submitted field before you have to
    even think about it on the receiving end. Asking users to enter dates in
    some ridiculous localized format like dd/mm/yyyy or mm/dd/yyyy is just
    asking for trouble!

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    "Sean" <anonymous@discussions.microsoft.com> wrote in message
    news:1FC749BB-1D41-4501-80C3-2E736A8E488B@microsoft.com...
    > Im trying to change the date format entered into a textbox from dd/mm/yy
    > to yyyy/mm/dd so as my stored procedure is run correclty. The date is
    > entered in a textbox called date. I attemped to use the line: -
    >
    > newdate = year(lsDate) & "/" & month(lsDate) & "/" & Day(lsDate)
    >
    > in order to change the date format in the background, but it hasn't seemed
    > to have worked. Can anyone show me where I've went wrong. Thank you very
    > much for any help anyone is able to give me.
    >
    > <%
    > lsDate = Request.Form("date")
    > newdate = year(lsDate) & "/" & month(lsDate) & "/" & Day(lsDate)
    > set dbconn = server.CreateObject("ADODB.Connection")
    > set lrstLog = server.CreateObject("ADODB.Recordset")
    >
    > dbConn.Open Application("connectionString")
    > 'dbconn.Open "DSN=WEBaccounts;uid=patrice;pwd=gillan;PageTimeou t =5;"
    > 'dbconn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
    > ID=sa;pwd=;Initial Catalog=cms_out;Data Source=sunaccserv"
    >
    > lrstLog.Open "ByWeekEnding '" & newdate & "'", dbconn, 3
    >
    > %>

    Aaron Bertrand [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