473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Javascript cookie "Type Mismatch" solution

I have some javascript ASP code that sets the expiry date on a cookie
to five years from now. The code worked until today, when I got the
following error message:

Microsoft JScript runtime (0x800A000D)
Type mismatch

The code was

var expiryDate=new Date();
expiryDate.setYear(expiryDate.getYear()+5);

Response.Cookies(cookieName).Expires=DateToExpires (expiryDate);

function DateToExpires(myDate)
{
return
String(theDate.getMonth())+"/"+theDate.getDate()+"/"+theDate.getFullYear();
}

DateToExpires returns "4/31/2010"; this is the correct format for
Expires.

See the problem? APRIL HAS ONLY 30 DAYS! I forgot that the value of
theDate.getMonth() runs from 0 to 11. The proper code is

function DateToExpires(myDate)
{
return
String(theDate.getMonth()+1)+"/"+theDate.getDate()+"/"+theDate.getFullYear();
}

which returns "5/31/2010" (which is actually 5 years from now!)

I hope that this helps someone.

- David Gauntt

Jul 22 '05 #1
1 2782
dm**********@yahoo.com wrote:
function DateToExpires(myDate)
{
return
String(theDate.getMonth())+"/"+theDate.getDate()+"/"+theDate.getFullYear();
}


myDate and theDate ? Re-check your object names.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #2

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

Similar topics

9
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript">...
3
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and...
2
by: Andrew Proctor | last post by:
Hello This is not a big problem, but I was hoping someone a bit more knowlegable than I could explain something to me. I have a simple function behind a form which writes changed values to a...
1
by: Brian Begy | last post by:
Anyone seen this? "Type mismatch could be due to the mixing of a file reference with a project reference " We have solution we are trying to upgrade to VS 2005. We have about 10 projects in...
1
by: melda | last post by:
I am a real beginnner in ASP. Due to increasing demands on dynamic website, I've been working on ASP website now. I use a ready to use CMS program and right now I've been trying to combine a calendar...
1
by: ApexData | last post by:
Access2k I WAS getting the following error when using the MID function: Run Time Error '13' Type Mismatch I have a new single form, unbound with 1-button on it that uses the following code:...
5
by: Davros9 | last post by:
Trying to get Regular Expressions working....... ---------------- Public Function SepString(InField As String) As String ''seperates on space and comma Dim RE As New RegExp Dim Matches As...
17
imrosie
by: imrosie | last post by:
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....not sure why. Can anyone point me in the right direction?? thanks ...
3
by: bxscikid | last post by:
I am using VB 6 in order to clear a listbox (lststuff) containing material entered by the user via input boxes. I am trying to utilize a command button which will clear the list for the user. When...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.