Hey edwilli, i tried doing cInt(fromDate) and i tried cInt(fromMonth), cInt(fromDay), cInt(fromYear) but it gives me a type mismatch error...
what does datepart do?
Main Topics
Browse All TopicsHow do you convert a string into an integer in vbscript? I've tried to find something but i can't find anything.
fromDate = Request("datefrom")
fromMonth = Left(fromDate,2)
fromDay = Right(Left(fromDate,5),2)
fromYear = Right(fromDate,2)
i want to turn fromMonth, day and year into integers so i can use < > signs and compare dates.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
silentScope,
try this test page... assuming that you entered a correct date with your format... it is already a number why do you need to use the cint... without still roduce the sam output...
===save this as test8.asp
<%
if request.form("Submit") = "Submit" then
fromDate = Request("datefrom")
fromMonth = Left(fromDate,2)
fromDay = Right(Left(fromDate,5),2)
fromYear = Right(fromDate,2)
if fromMonth < 12 then
response.write "true"
else
response.write "false"
end if
response.write fromDay
response.write fromYear
end if
%>
<form name="form1" method="post" action="test8.asp">
<input type="text" name="datefrom">
<input type="submit" name="Submit" value="Submit">
</form>
HTH..
HAppy programming...
silentScope,
try to replace the asp of my previous post with this...
it first check the date if valid or not.
<%
if request.form("Submit") = "Submit" then
fromDate = Request("datefrom")
if IsDate(tmpmydate) = "True" then
fromMonth = Left(fromDate,2)
fromDay = Right(Left(fromDate,5),2)
fromYear = Right(fromDate,2)
if fromMonth < 12 then
response.write "true"
else
response.write "false"
end if
response.write fromDay
response.write fromYear
else
response.write "Kindly input a valid date..."
end if
end if
%>
HTH...
Happy programming...
I appreciate all the comments, but im so confused.
When i do the fromMonth
fromMonth = Left(fromDate,2)
fromDay = Right(Left(fromDate,5),2)
fromYear = Right(fromDate,2)
fromDate is a string that the user enters in, a date.
So fromMonth and fromDay and fromYear are all strings right? I'm curious how you turn them into integers.
In javascript, i did this:
var toDate = document.orderform.dateto.
var month = parseInt(toDate.substring(
var date = parseInt(toDate.substring(
var year = parseInt(toDate.substring(
Now im curious how you do something like that in vbscript?
You don't need to. Do this instead
dateFrom=cdate(request("da
fromMonth=month("dateFrom"
fromYear=year("dateFrom")
fromDay=day("dateFrom")
But if you would show us how you're comparing the dates, we can probably help you do that. It's better to compare the dates as dates, rather than go through all the breaking it down to do a comparison.
'In VBScript, as you know, all variables are type variant,
'but we can use the following functions to specify the
'sub-type of a variable:
'CBool - Variant of subtype Boolean
'CByte - Variant of subtype Byte
'CCur - Variant of subtype Currency
'CDate - Variant of subtype Date
'CDbl - Variant of subtype Double
'CInt - Variant of subtype Integer
'CLng - Variant of subtype Long
'CSng - Variant of subtype Single
Dim strValue
Dim intValue
strValue = "24" 'Request.Form("Amount")
'You can double-check that the string contains a valid number
If IsNumeric(strValue) Then
'Make intValue a variant of sub-type integer
intValue = CInt(strValue)
End If
'Also, you can check the subtype of a variant using the TypeName function
MyType = TypeName(strValue) ' Returns "String".
MyType = TypeName(intValue) ' Returns "Integer".
Check out more detailed info at:
http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: edwilliPosted on 2003-02-06 at 12:33:45ID: 7896611
Datepart("d", fromDate)
Datepart("m", fromDate)
Datepart("yyyy", fromDate)
you can also cInt(fromDate) > cInt(toDate)