ckroon
Posts: 869
|
| Posted: 07/09/2008, 11:21 PM |
|
Hi All..
My php skills are coming along I must say.. thanks to all of you...
Following the advice of a previous post I am trying to set a date value by using the array.
I have a display label (Off_date) and two hidden date fields: enrdate and termstartdate
All these fields are set to Date format with yyyy-mm-dd as the db format. LongDate as the display format.
I put the following code on the grids BS event:
global $DBConnection1;
$Container->enrdate->SetValue(CCDLookUp("schoolenrolldate","classlist","studentid=".CCGetFromGet("sid",0),$DBConnection1));
$Container->termstart->SetValue(CCDLookUp("sdterms_rcstartdate","school_data_terms","schooldatatermsid=".CCGetFromGet("t",0),$DBConnection1));
$date1=$Container->enrdate->GetValue();
$date2=$Container->termstart->GetValue();
if ($date1[0] > $date2[0] )
$Container->Off_date->SetValue( $date1);
if ($date1[0] < $date2[0] )
$Container->Off_date->SetValue( $date2);
echo "$date1[0]---$date2[0]";
The echo shows both dates nicely (but not as datetime as I expected).
When I echo $date1[0] or $date2[0] it shows me: '2' so the compare is getting nullified.
Anyone spot my error?
_________________
Walter Kempees...you are dearly missed. |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/10/2008, 1:45 PM |
|
Hi
I grapled with this problem some time ago and posted some info that might help you.
I did not go thru your code above but, since you know what you are trying to do, take a look a this post and let me know if it helps.
http://forums.yessoftware.com/posts.php?post_id=97052
Oops,
After I looked at the old post, I see it is you again.
Ok, I took a quick look at the code above. I think the problem is just doing a CCDlookup. I am not sure but it is possible that CCDLookup does not run the returned value from DB through the dbformat routines. (Be sure endate and termdate are defined as date controls with appropriate formats set.)
Take a look in the php file and see how standard code loads a control with a date. You might be able to quickly see how to put a date into a control properly using CCDLookup.
That is my guess from looking at the code above.
Another thought is if the two date values are already in a database, why don't you just specify them in the control definition and let the page load them. The you do not have to do a CCDLookup
I am sort of rushed right now. If that does not help, let me know and I will take some time and help you work it out.
Have fun.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ckroon
Posts: 869
|
| Posted: 07/10/2008, 3:00 PM |
|
Hi again. Yes that was the post I was referring to, but that thread was closed so I had to open a new one.
Ok.. I went back to basics and have made some progress...since both comparions dates were already in the db in yyyy-mm-dd format.
This is what I have now:
global $DBConnection1;
$Container->enrdate->SetValue(CCDLookUp("schoolenrolldate","classlist","studentid=".CCGetFromGet("sid",0),$DBConnection1));
$Container->termstart->SetValue(CCDLookUp("sdterms_rcstartdate","school_data_terms","schooldatatermsid=".CCGetFromGet("t",0),$DBConnection1));
$Component->SetValue( $Container->Off_date->GetValue());
if ($Container->enrdate->GetValue() > $Container->termstart->GetValue())
$Component->SetValue( $Container->enrdate->GetValue());
if ($Container->enrdate->GetValue() < $Container->termstart->GetValue())
$Component->SetValue( $Container->termstart->GetValue());
$date1=$Container->enrdate->GetValue();
$date2=$Container->termstart->GetValue();
echo "$date1---$date2";
The echos are perfect.
The label Off-date filled with December 31, 1969 no matter what I tried.. until I took the Date format off it and made it just text..
Now it works! but how do I get it to display in mm/dd/yy... the yyyy-mm-dd is just too ugly.
_________________
Walter Kempees...you are dearly missed. |
 |
 |
|