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

 DATEDIFF Function

Print topic Send  topic

Author Message
PeterJ


Posts: 90
Posted: 03/05/2005, 8:47 PM

Hi

CCS returns an error when I use:
DATEDIFF(spdatestart, datestart) AS stScore
in the Data Source facility using SQL. This appears to be the correct argument. I presume DATEDIFF is a logical argument in CSS? Do the fields have to be date fields? I have them set as VARCHAR

Thanks
View profile  Send private message
peterr


Posts: 5971
Posted: 03/05/2005, 11:13 PM

Please always provide the complete error message when you see an error! Without knowing details there is no way to know if CCS returns an error or your database or PHP.
Though I don't think that DATEDIFF exists in CCS thus if you use it you must construct correct SQL statement or PHP command that works without CCS.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterJ


Posts: 90
Posted: 03/06/2005, 3:02 AM

Sorry, hanging my head in shame. Should have known better. The error was

"[MySQL][ODBC 3.51 Driver][mysqld-4.8.0nt] You have an error in your sql syntax. Check the manuak that corresponds to your MySQL server version for the rights syntaxt to use near (spdatestart, datestart) AS stScore FROM ((leaguechoices INNER"
View profile  Send private message
peterr


Posts: 5971
Posted: 03/06/2005, 12:12 PM

Looks like this error is returned by MySQL. I found DateDiff example at http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
Hopefully it can help. Keep in mind that your SQL must work outside of CCS directly with MySQL, so it may be best to test it against MySQL.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterJ


Posts: 90
Posted: 03/07/2005, 12:25 AM

I solved the calculation yesterday by using TO_DAYS(DATE1 - DATE2) as DATEDIFF doesn't work.

thanks for your assistance
View profile  Send private message
DonB
Posted: 03/07/2005, 6:34 AM

DATEDIFF and other date-arithmetic functions were added as of MySQL 4.1.1.
Numerous other features have been added in this and other versions, so
always be aware of what version of MySQL your server is running.

--
DonB

http://www.gotodon.com/ccbth


"PeterJ" <PeterJ@forum.codecharge> wrote in message
news:5422c0ff95d5b0@news.codecharge.com...
> I solved the calculation yesterday by using TO_DAYS(DATE1 - DATE2) as
DATEDIFF
> doesn't work.
>
> thanks for your assistance
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

PeterJ


Posts: 90
Posted: 03/07/2005, 9:44 AM

Hello DonB

Therein lies the problem. I'm using V3.23.49 locally and V4.0.22 remotely.

Thanks for pointing that out.

Thanks to peterr too. I have looked at the page as advised which reaffirms your point.
View profile  Send private message
suzanna
Posted: 03/20/2005, 7:32 PM

hi..
sori my english so bad!!

my prob is to calculate the penalty if someone late send book..
how i want to compare dte date in database with the date today.
date from the database is date where d someone must send the book..

penalty=dateSEnd-dateToday

plzz
PeterJ


Posts: 90
Posted: 03/21/2005, 9:23 AM

suzanna

Try MySQL Query:

(TO_DAYS(dateSEnd) - TO_DAYS(NOW())) AS penalty

and display the result as a label in your grid
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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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