This content has been marked as final. Show 5 replies
Can't you try the following
var dob:Date = DateField.stringToDate("30/12/2008", "DD/MM/YYYY");
one of the frustrating things with the datefield object is that you can't simply assign it a date object as follows
var d:Date=new Date();
To set the Datefield with a date you need to do the following
dateField1.selectedDate=new Date(d.fullYear,d.month, d.date);
Hi amthekkel ,
Thanks for the reply.
I actually tried what you suggested before itself, but the problem is that instead of "30/12/2008" in your example, i have "30-Dec-2008" in my database, which is a string object. That's why i'm not able to use this function.
First problem with this type of string date is , it has "-" seperated values and the second one is it has "mmm" format for month.
If you can't control the database format, you will just have to parse the string and build a Date() object. Since the string is delimited by "-", this will be trivial.
The issue with your dates having a hyphen instead of a backslash is not an issue.
var dob:Date = DateField.stringToDate("30-12-2008", "DD-MM-YYYY");
this will work. The only problem is the converting your month names like Dec.. Workaround would be to create a small parser to parse your date string, but then it might be equally easier to create your date object using the parser rather than using the stringToDate method. Sorry i couldnt be of more help, shall keep you posted if I manage to solve the issue.
good luck in the meantime.
Thanks Guys for all your help and time. I some how managed to find a solution. :)
I used a split function to split the date to date, month and year,
var exp_date :String = _userDetails.date;
var date1:Array = exp_date.split( '-' );
var date:int = date1;
var mon:String = date1;
var year:int = date1;
Converted the string month to an integer and then selected the date in the Datefield using