473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split, convert date question ??

Hi,

I have a form which is posting a user entered date to an asp page.
The date is then used in a SQL string.

The format of the date is received as dd/mm/yyyy, with the user typing
the '/' as well

how can I convert it to yyyy-mm-dd

----------------

I have tried this, but I think I need to strip out the '/' ??, as it is
not working

D1 = cdate(request.f orm("date"))

strDay = Day(D1)
strMonth = Month(D1)
strYear = Year(D1)

NewstrDate = strYear & "-" & strMonth & "-" & strDay

Appreciate your help, thanks so much :-)

Oct 4 '06 #1
3 5733
"David" <da*********@sc ene-double.co.ukwro te in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Hi,

I have a form which is posting a user entered date to an asp page.
The date is then used in a SQL string.

The format of the date is received as dd/mm/yyyy, with the user typing
the '/' as well

how can I convert it to yyyy-mm-dd

----------------

I have tried this, but I think I need to strip out the '/' ??, as it is
not working

D1 = cdate(request.f orm("date"))

strDay = Day(D1)
strMonth = Month(D1)
strYear = Year(D1)

NewstrDate = strYear & "-" & strMonth & "-" & strDay

Appreciate your help, thanks so much :-)
You almost had it - you need to use the Split() function:

<%
Function changeUserDate( userDate)
temp = Split(userDate, "/")
strDay = temp(0)
strMonth = temp(1)
strYear = temp(2)
changeUserDate = strYear & "-" & strMonth & "-" & strDay
End Function

Response.Write changeUserDate( Request.Form("d ate"))
%>

Personally, I use a javascript calendar so that users can select dates for
forms. That way I can manage the format of the input and don't have to do
anything with it serverside, except check it's there (and check that end
dates come after start dates etc...).

There are a number of these knocking about on javascript code sites. Google
will find one for you easily enough.

--
Mike Brind
Oct 4 '06 #2
On 04 okt 2006, you wrote in microsoft.publi c.inetserver.as p.general:
<%
Function changeUserDate( userDate)
temp = Split(userDate, "/")
strDay = temp(0)
strMonth = temp(1)
strYear = temp(2)
changeUserDate = strYear & "-" & strMonth & "-" & strDay
End Function

Response.Write changeUserDate( Request.Form("d ate"))
%>
<%
Response.Write changeUserDate( Request.Form("d ate"))

Function changeUserDate( userDate)
dim result(3)
temp = Split(userDate, "/")
result(2) = temp(0)
result(1) = temp(1)
result(0) = temp(2)
changeUserDate = Join(result,"-")
End Function
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 4 '06 #3
"Evertjan." <ex************ **@interxnl.net wrote in message
news:Xn******** ************@19 4.109.133.242.. .
On 04 okt 2006, you wrote in microsoft.publi c.inetserver.as p.general:
><%
Function changeUserDate( userDate)
temp = Split(userDate, "/")
strDay = temp(0)
strMonth = temp(1)
strYear = temp(2)
changeUserDa te = strYear & "-" & strMonth & "-" & strDay
End Function

Response.Wri te changeUserDate( Request.Form("d ate"))
%>

<%
Response.Write changeUserDate( Request.Form("d ate"))

Function changeUserDate( userDate)
dim result(3)
temp = Split(userDate, "/")
result(2) = temp(0)
result(1) = temp(1)
result(0) = temp(2)
changeUserDate = Join(result,"-")
End Function
%>
Now that I like :-)

--
Mike Brind
Oct 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3260
by: oliver | last post by:
hi there i'm experimanting with imaplib and came across stringts like (\HasNoChildren) "." "INBOX.Sent Items" in which the quotes are part of the string. now i try to convert this into a list. assume the string is in the variable f, then i tried f.split() but i end up with
2
12803
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces, the employer code in column 23 for 29 spaces and employer description in column 53 for 30 spaces. I have tried modifying an existing file with no real...
4
5351
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm...
4
2416
by: kinne | last post by:
The following code is supposed to reverse the date in "yyyy-mm-dd" format, but it produces different results in Firefox 1.0 and in Internet Explorer 6SP1. In Firefox, the result is correct ("2004-11-29") but it's wrong in Internet Explorer 6SP1 ("00:20:15-11-29"). If I change "dateParts" to "dateParts", it's exactly the opposite that occures:...
7
4457
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns System_String. I don't see a difference in the previous code and what I have now. Can anyone find where I went wrong? Thanks a bunch! //Open new stream...
2
5072
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings set to "en-UK" and date to
5
8690
by: Sen Haerens | last post by:
I'm using string.split(/^$/m, 2) on a curl output to separate header and body. There’s an empty line between them. ^$ doesn’t seem to work... Example curl output: HTTP/1.1 404 Not Found Date: Wed, 22 Feb 2006 00:01:45 GMT Server: Apache/1.3.33 (Darwin) PHP/5.1.2 mod_perl/1.29 Transfer-Encoding: chunked Content-Type: text/html;...
6
2158
by: Saurabh | last post by:
Hi everyone, I am looking for some expert advise to get me out of trouble. I am looking for a solution in C# which will allow me to split the below string in the format provided. The String.Split() allows only a single char as a delimiter.So I cannot use that as well. Original String "*** MASTER (Supervisor) *** September 23, 1997 at ...
2
3743
by: Shawn Minisall | last post by:
I'm trying to unpack a list of 5 floats from a list read from a file and python is telling me 5 variables are too many for the string.split statement. Anyone have any other idea's? NOTE: the only reason I convert it to a float instead of just leaving it as a string in the loop is because I have to have it printed out as a float besides the...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.