CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Resolved : Date Format Change While Saving Record

Print topic Send  topic

Author Message
girish_327


Posts: 108
Posted: 08/05/2011, 11:36 AM

Hello All,
I would like to custom insert the one query in which I get Date from Record.

Record Date is in dd/mm/yyyy format and I would like to insert a query which requires date in yyyy-mm-dd format please help me how do I change the date format.

I tried
$today = $closing_record->closing_date->GetValue(); $today = CCFormatDate($today ,array("yyyy"," ","mmm"," ","d")); // outputs 2006-01-24 

but no luck.

Thanks in Advance
Girish

_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
scarvello

Posts: 64
Posted: 08/05/2011, 2:20 PM

I suggest first to manually insert in your db with a sql statement. Then , by using CCFormatDate function, format your date field by reflecting the statement used before.
View profile  Send private message
girish_327


Posts: 108
Posted: 08/05/2011, 11:20 PM

Hello ,
Thanks for suggestion but I just want to know how do I store textbox date into database. Manual date insert works.

Can anybody tell me whats wrong in below code
$today = CCFormatDate(CCParseDate($closing_record->closing_date->GetValue(),array("yyyy"," ","mm"," ","dd"))) ;

This stores date as 0000-00-00 .

My Default Date format is dd/mm/yyyy
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
datadoit
Posted: 08/06/2011, 7:09 AM

In a nutshell...

CCFormatDate(The Date, The Format You Desire)
CCParseDate(The Date, The Format of The Date)

So, CCParseDate() says give me a Julian representation of the text
formatted date.

CCFormatDate() says take that Julian date and give it back to me in such
and such text format.

CCFormatDate(CCParseDate($Container->closing_date->GetValue(),
array("dd", "/", "mm", "/", "yyyy")), array("yyyy", "/", "mm", "/", "dd"))

Sometimes your eyes can get crossed nesting functions and objects like
that. The below is a longwinded way of doing the same thing:

$TheDate = $Container->closing_date->GetValue(); //our date object.
$TheDateParsed = CCParseDate($TheDate, array("dd", "/", "mm", "/",
"yyyy")); //parsed from text format to Julian format.
$TheFormatIWant = array("yyyy", "/", "mm", "/", "dd"); //hold the new
format I want in a variable.
$TheNewDate = CCFormatDate($TheDateParsed, $TheFormatIWant); //give me
my date back in the new text format I want.
girish_327


Posts: 108
Posted: 08/07/2011, 5:33 AM

Hi,
I am getting output date is : 0001-01-01

Please see my DB Insert Code Might bewrong in this code :

  
$SQL = "INSERT INTO production (production_id , production_date , grade_id , opening , sales , closing , production ) VALUES (".  
		   "NULL , '". $TheNewDate ."' , '1' , '". $opening ."' , '". $sales ."' , '". $cl_grade_d ."' , '".$production."')";  
  $DBdenish_patel->query($SQL);  
  

_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
girish_327


Posts: 108
Posted: 08/07/2011, 5:39 AM

Hi datadoit,
THANKS FOR YOUR HELP. My working code is

  
$TheDate = CCFormatDate(CCParseDate($closing_record->closing_date->GetFormattedValue(),array("dd", "/", "mm", "/", "yyyy")), array("yyyy", "-", "mm", "-", "dd"));  
  
  
$SQL = "INSERT INTO production (production_id , production_date , grade_id , opening , sales , closing , production ) VALUES (".  
		   "NULL , '". $TheDate ."' , '1' , '". $opening ."' , '". $TheDate ."' , '". $cl_grade_d ."' , '".$production."')";  
  $DBdenish_patel->query($SQL);  
  

_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message

Add new topic Subscribe to topic   


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.