For those familiar with coldfusion, this function might be of use.  It
is called DateAdd and takes 3 parameters just like the CF version.  It
can be extended for other date parts, but this code snipit is only for
modifying the year of a date passed.  I have used both for passing
dates to webservice calls and they work perfectly.  I hope it helps.

function DateAdd(datepart, value, tmpDate):Date{
        // tmpDate is a date in the YYYY,MM,DD,HH,MM,SS format
        if (tmpDate == ''){tmpDate = Now();}
        var new_date:Date;
        var tmpValue:Number;
        if (datepart == 'yyyy'){
                tmpValue = tmpDate.getFullYear() + value;
                new_date = new
Date(tmpValue,tmpDate.getMonth(),tmpDate.getDate(),tmpDate.getHours(),tmpDate.getMinutes(),tmpDate.getSeconds(),tmpDate.getMilliseconds());
        }
        //alert('oldDate:' + tmpDate.toString() + ' & newDate:' +
new_date.toString());
        return new_date;
}

I also created a version of Now() for this to easily create dates w/o
having to set a variable first.  Very simple, but here it is:


function Now():Date{
        var today_date:Date = new Date();
        return today_date;
}

--- In [email protected], "gevgelija50" <[EMAIL PROTECTED]> wrote:
> 
> .NET has a nice set of date functions that will allow you to add or 
> subtract days from a selected date. 
> 
> For Example: 
> 
> my date is 12/31/2004
> myDate.AddDays(1) would set the myDate equal to 01/01/2005
> 
> From reading the documentation, I don't see such capabilities in the 
> Flex Date class. Is there any such functionality WITHOUT re-inventing 
> the wheel and writing your own function from scratch?
> 
> Thanks,
> Alex





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to