CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> Archive -> GotoCode Archive

 Date Search

Print topic Send  topic

Author Message
Posted: 01/03/2002, 7:21 AM

I would like to pass search parameters which are dates formatted as dd-mm-YY while the date field in MySQL database is YY-mm-dd. How do I convert these dates to the correct format for SQL before passing them as parameters? Someone may have posted this before but I can't seem to find it. Can anyone help. I'm using PHP/MySQL. Thanx for any help.
Posted: 01/04/2002, 1:45 AM

if you're sure that the date was passed in dd-mm-yy format from search from to grid from you can format date to MySQL format (yyyy-mm-dd) before search is executed. Add the code like below to result grid form -> Open event. Don't forget to replace table alias and field names with your own ones:

$pdate_assigned = get_param("date_assigned");
if ($pdate_assigned !="")
$day = substr($pdate_assigned, 0, 2);
$month = substr($pdate_assigned, 3, 2);
$y = substr($pdate_assigned, 6);
$mysql_date = $y. "-". $month. "-". $day;
$sWhere = str_replace($pdate_assigned, $mysql_date, $sWhere);
Posted: 01/04/2002, 2:01 AM

Thanx, Nicole. I did manage to find a similar post and now you've confirm that I need to modify the sWhere variable in the Open event. What I actually did was to leave it out of the input parameters and then in the Open event, converted the date format and appended it to the sWhere variable. It seems to be working fine. Thanx very much for your advice.


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.