CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 get the week number form the inserted date

Print topic Send  topic

Author Message
kriska

Posts: 18
Posted: 01/27/2010, 10:13 PM

hi all i want to get the week number for the inserted and i want to add it to the database table field.
in order to do that what i write was the code given bellow
$SQL = "UPDATE song_of_the_day ".
"SET week_number = WEEK( " .$CCGetParam("sng_date"). " )
WHERE sng_id =". mysql_insert_id() ;
but it doesnt seems work.can any one help me to get through this.
here i used WEEK mysql function in order to get the week no. and pass the date as sng_date which is inserting in the front end of the form.

thank you
View profile  Send private message
datadoit
Posted: 01/28/2010, 7:28 AM

Kriska, MySQL and/or PHP only understand julian time formats.

Example: Right now it's January 28th, 2010 at 10:21 am where I'm at
(GMT-5). To a UNIX system it's 1264692085. Not 1/28/10, Jan 28, 2010,
01-28-10, etc.

So unless your CCGetParam("sng_date","") is in a format that the
computer understands, it will not get you the correct week that you
seek. You will first need to unformat or parse the correct date. Look
in the help file for CCParseDate() and CCFormatDate() functions. In
this case, you'll parse the date before working with it.
laneoc

Posts: 154
Posted: 01/28/2010, 8:40 PM

Convert your date value -- $CCGetParam("sng_date") -- to whatever your connection needs by using CCS' ToSQL function as follows.

$YourConnection = new clsDBwhatever;
$ReformattedDate = $YourConnection->ToSQL($CCGetParam("sng_date"),ccsDate)

$SQL = "UPDATE song_of_the_day ".
"SET week_number = WEEK($ReformattedDate)
WHERE sng_id =". mysql_insert_id() ;

Note that you won't need the quote marks about $ReformattedDate within the WEEK function due to how ToSQL sets up $ReformattedDate.

LO
_________________
Lane
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.

Web Database

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

Home   |    Search   |    Members   |    Register   |    Login


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