CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 problem formatting a date

Print topic Send  topic

Author Message
Sarah
Posted: 03/14/2002, 11:35 AM

I used the example here> http://www.gotocode.com/art.asp?art_id=132& to format some dates, but for some reason if there was no date submitted,(the database has 0000-00-00), the instead of 00-00-0000 showing on the record page, it shows 12/31/1969. I have no idea where that date came from. Anyone no what the problem is?
CodeCharge Support
Posted: 03/15/2002, 2:27 AM

Sarah,
to display empty date (or any temp date value) when it equals to "0000-00-00" you should improve format date function code. E.g. in such way:
switch ($format)
{
case 1:
if (($year=="")||($month=="")||($day==""))
$res = "00/00/0000";
else
$res = date("d/m/Y", mktime(0,0,0, $month, $day, $year));
break;
case 2:
if (($year=="")||($month=="")||($day==""))
$res = "00/00/0000";
else
$res = date("m/d/Y", mktime(0,0,0, $month, $day, $year));
break;
case 3:
if (($year=="")||($month=="")||($day==""))
$res = "00-00-0000";
else
$res = date("d-m-Y", mktime(0,0,0, $month, $day, $year));
break;
}
CodeCharge Support
Posted: 03/15/2002, 2:27 AM

Sarah,
to display empty date (or any temp date value) when it equals to "0000-00-00" you should improve format date function code. E.g. in such way:
switch ($format)
{
case 1:
if (($year=="")||($month=="")||($day==""))
$res = "00/00/0000";
else
$res = date("d/m/Y", mktime(0,0,0, $month, $day, $year));
break;
case 2:
if (($year=="")||($month=="")||($day==""))
$res = "00/00/0000";
else
$res = date("m/d/Y", mktime(0,0,0, $month, $day, $year));
break;
case 3:
if (($year=="")||($month=="")||($day==""))
$res = "00-00-0000";
else
$res = date("d-m-Y", mktime(0,0,0, $month, $day, $year));
break;
}

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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