Ask a Question related to ASP Database, Design and Development.
-
Sean #1
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
-
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... -
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... -
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... -
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")); ?> -
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... -
Aaron Bertrand [MVP] #2
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



Reply With Quote

