[thelist] ASP/JScript/SQL Server and date formatting

Sarah Sweeney poohbear at designshift.com
Fri Dec 12 07:37:44 CST 2003


> I am working on a site using ASP and JScript. I have a page where I am 
> trying to output a list of events which are saved in an SQL Server 
> database. I want to use some JScript date functions (e.g. getDay(), 
> getMonth(), etc) on the date as it is returned from the database, but it 
> seems that JScript doesn't like the format the date is returned in. If I 
> output "typeof mydate", it returns "date", but if I try to output 
> "mydate.getMonth()", I get the error message "'mydate' is null or not an 
> object". Does anyone know how I can get past this?

I guess no one knew the answer to this one, but that's ok, cause I ended 
up finding one myself :) In case anyone is interested, this is what I 
did with the date retrieved from the database (mydate) to make JScript 
accept it:
   var jsdate = new Date();
   jsdate.setTime(Date.parse(mydate));
The Date.parse() method takes a date string and creates a Date object 
from it.

Sarah



More information about the thelist mailing list