# dateChooser.selectedDate Conditional Statement

**URL:** <https://forum.kirupa.com/t/datechooser-selecteddate-conditional-statement/280189>\
**Category:** flash\
**Created:** [January 23, 2009, 9:33pm UTC](https://forum.kirupa.com/t/datechooser-selecteddate-conditional-statement/280189 "2009-01-23T21:33:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk8er5960](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@sk8er5960](https://forum.kirupa.com/u/sk8er5960)\
**Post date:** [January 23, 2009, 9:33pm UTC](https://forum.kirupa.com/t/datechooser-selecteddate-conditional-statement/280189/1 "2009-01-23T21:33:12Z")

</div>

all I want to do is check to see if a date is selected, trace something; else, trace something else. simple enough right?

assuming my\_dc as DateChooser instance name, I use:

_this.onEnterFrame = function() {  
yesterday = new Date(2009, 0, 22);  
my\_dc.selectedDate = yesterday;  
}_

works, no other date can be selected beside the one specified in the “yesterday” variable.

if I put this code in the my\_dc dateChooser component:  
_on(change) {  
trace(this.selectedDate);  
}_

works, output is the date you just clicked.

now, I try to do a conditional statement… anywhere:  
_this.onEnterFrame = function() {  
yesterday = new Date(2009,0,22);  
if(my\_dc.selectedDate == yesterday) {  
trace(“that’s yesterday”);  
}else{  
trace(“that’s not yesterday”;  
}  
}_

or in the component:

on(change) {  
yesterday = new Date(2009,0,22);  
if(my\_dc.selectedDate == yesterday) {  
trace(“that’s yesterday”);  
}else{  
trace(“that’s not yesterday”;  
}  
}

neither work!:{

i’ve tried different things in the conditional statement like:

_if(my\_dc.selectedDate == new Date(2009,0,2))  
if(my\_dc.selectedDate == 2009,0,2)  
if(my\_dc.selectedDate == ‘2009,0,2’)  
if(my\_dc.selectedDate == (2009,0,2))_

and a lot of others and I can’t get this working…

I was wondering if someone knew why i can’t use the dateChooser.selectedDate property in a conditional statement, or how I’m doing it wrong.

thanks
