Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATE COMPARE FROM XML REVISITED

Status
Not open for further replies.

Sammybobo

Programmer
Apr 4, 2003
87
US
Hi:

I am having the same problem as the one in thread250-791975. There was no answer posted then and I wonder if someone could give me a quick help.

I am extracting a date from an XML node in the form of: 2004,7,29. When I tried to convert it to date using the format below I get an "Invalid date" error:
x=new Date(myxmlnode)
But if I use a literal format like this, I have no error:
y=new Date(2004,7,29) // yields the date

Also, when I trace myxmlnode, it yields the right output: 2004,7,29

I need to use that to determine the number of weeks between that date and the current date. Please help!
 
You have to give numbers to Date() rather than strings.
[tt]// (AS2)
var dateArray:Array = myxmlnode.split(",");
var year:Number = parseInt(dateArray[0]);
var month:Number = parseInt(dateArray[1])-1;
var date:Number = parseInt(dateArray[2]);
var x:Date = new Date(year, month, date);
trace(x);
//[/tt]

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top