Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2008, 07:28 AM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Salims
Default Using cdate function in dreamweaver

Hi,
I'm having problem with this code
<%
dim dob
dob=cdate(request.form("staffdd")+"/"+request.form("staffmonth")+"/"+request.form("staffyear"))
%>

I'm trying to append the values selected in my dropdown menus called: staffdd (for day on the day dropdown list), staffmonth(form month on the month dropdown list) and staffyear (for year on the year dropdown list).
I am using dreamweaver 8 and it is giving me: type mismatch error "cdate". Please how do i go about solving this error so it can display the date and insert it into a database.


 
Old January 17th, 2008, 09:21 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

Salims

I may be misunderstanding your function but try below

Code:
<%
dim dob,staffdd,staffmonth,staffyear

staffdd = request.form("staffdd")
staffmonth = request.form("staffmonth")
staffyear = request.form("staffyear")

dob=cdate( & staffdd & "/" & staffmonth & "/" & staffyear )
%>
Hope this helps

Aspless

 
Old January 17th, 2008, 06:42 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Firsty you should look up VBScript operators. You are using the addition operator (+) when you should be using the concatenation operator (&)

You are getting this error because one or more of the three values inside your cDate function is not valid. to show an example of this. Run this code:

<%
dim dob,d,m,y
d = "277"
m = "10"
y = "1972"

dob=cdate(d & "/" & m & "/" & y)
response.write dob
%>

This will give you the same error because one of your values is not valid. The 'd' variable requires a value less than the total number of days possible in the given month. Now chnage the 'd' value from '277' to '27' and run the code, it will now work.

So to fix your issue validate the form variables before they are submitted to ensure they will always be valid.

TIP - Use the IsDate function to determine if date can be converted to a date or time

Wind is your friend
Matt
www.elitemarquees.com.au





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
DreamWeaver 8 - 'pin' function crmpicco Dreamweaver (all versions) 0 November 1st, 2005 11:15 AM
Using CDate() dinkarsinha General .NET 3 December 13th, 2004 08:11 AM
CDate problem ne0 Classic ASP Components 5 May 13th, 2004 06:17 PM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.