CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Point me in the right direction please.

Print topic Send  topic

Author Message
ncjimgir

Posts: 18
Posted: 04/17/2007, 6:54 PM

I am using PHP and MySQL. I am trying to figure out what expression I need to use to get the date from the URL and add 1 day to it.

Any help for a beginner would be great.





_________________
Jim
View profile  Send private message
Benjamin Krajmalnik
Posted: 04/17/2007, 7:31 PM

As a beginner, Google is your friend.
I googled "php dateadd", and in the online documentation for PHP, under the
date functions, I found the following:

# a function to subtract from or add seconds or minutes or hours or days or
months or weeks or years to a specified date and return the updated date

#=========================================

#$newdate = dateadd("d",3,"2006-12-12"); # add 3 days to date
#$newdate = dateadd("s",3,"2006-12-12"); # add 3 seconds to date
#$newdate = dateadd("m",3,"2006-12-12"); # add 3 minutes to date
#$newdate = dateadd("h",3,"2006-12-12"); # add 3 hours to date
#$newdate = dateadd("ww",3,"2006-12-12"); # add 3 weeks days to date
#$newdate = dateadd("m",3,"2006-12-12"); # add 3 months to date
#$newdate = dateadd("yyyy",3,"2006-12-12"); # add 3 years to date
#$newdate = dateadd("d",-3,"2006-12-12"); # subtract 3 days from date

function dateAdd($interval,$number,$dateTime) {

$dateTime = (strtotime($dateTime) != -1) ? strtotime($dateTime) :
$dateTime;
$dateTimeArr=getdate($dateTime);

$yr=$dateTimeArr[year];
$mon=$dateTimeArr[mon];
$day=$dateTimeArr[mday];
$hr=$dateTimeArr[hours];
$min=$dateTimeArr[minutes];
$sec=$dateTimeArr[seconds];

switch($interval) {
case "s"://seconds
$sec += $number;
break;

case "n"://minutes
$min += $number;
break;

case "h"://hours
$hr += $number;
break;

case "d"://days
$day += $number;
break;

case "ww"://Week
$day += ($number * 7);
break;

case "m": //similar result "m" dateDiff Microsoft
$mon += $number;
break;

case "yyyy": //similar result "yyyy" dateDiff Microsoft
$yr += $number;
break;

default:
$day += $number;
}

$dateTime = mktime($hr,$min,$sec,$mon,$day,$yr);
$dateTimeArr=getdate($dateTime);

$nosecmin = 0;
$min=$dateTimeArr[minutes];
$sec=$dateTimeArr[seconds];

if ($hr==0){$nosecmin += 1;}
if ($min==0){$nosecmin += 1;}
if ($sec==0){$nosecmin += 1;}

if ($nosecmin>2){ return(date("Y-m-d",$dateTime));} else {
return(date("Y-m-d G:i:s",$dateTime));}
}

Depending on what format your URL's date is in, you may need to manipulate
it to use this function. You would retrieve it by using a
CCGetFromGet("yoururlparamname"). If it is already in the correct format,
you are o. Otherwise, you would use the CCParseDate and CCFormatDate
functions to place it in the correct format.

Hope this gets you going on the right track.

joseph2k

Posts: 72
Posted: 04/19/2007, 1:12 PM

you could try placing ( ) around statement but I have very poor results from doing calcs in SQL expressions.

If you output the SQL statement being used you will find problems in what CCS ends up using. So I usuallu just calculate outside, place in session variable or in hidden form and use that instead.

So to output what is being used in sql :
In the before select or after select statement

$qry = $Container->DataSource->SQL;

Print to file or screen what's in $qry

View profile  Send private message
ncjimgir

Posts: 18
Posted: 04/19/2007, 2:32 PM

Thanks for pointing me in the right direction.

I came up with this code:

CCGetFromGet("s_date_purchased"+1, NULL)


Where do I find a list of all the CC functions, I think I'm looking in the wrong place?
_________________
Jim
View profile  Send private message
ncjimgir

Posts: 18
Posted: 04/19/2007, 2:49 PM

Nope, that did not work. :(
_________________
Jim
View profile  Send private message
teke507

Posts: 69
Posted: 04/19/2007, 7:36 PM

I would try to use variables more they can help for example

$nextday = CCGetFromGet("s_date_purchased") + 1;

Im not 100% on the syntax but that should work once the syntax is correct

Then put the variable $nextday in the parameter field of your sql query

Remember though you have to declare the variable before you go to the server to execute the query otherwise it wont work... Let me know how it works....I have been posting for months now but only to ask question for i to am a beginner this is my first response to a question that is not mine.... Goodluck

p.s. I didn't test it out yet but i will when i get to work ill let you know any changes that i found needed to be made if any
View profile  Send private message
ncjimgir

Posts: 18
Posted: 04/19/2007, 7:42 PM

I really appreciate the time you've taken to answer my question. I'll do that same once I've become familiar with the program again.
_________________
Jim
View profile  Send private message
teke507

Posts: 69
Posted: 04/19/2007, 7:52 PM

Go to
http://support.yessoftware.com/tutorials.asp

then download the component reference manual it has all the CCS functions....
View profile  Send private message
ncjimgir

Posts: 18
Posted: 04/19/2007, 8:10 PM

Fantastic. THANKS
_________________
Jim
View profile  Send private message
DaveSause

Posts: 14
Posted: 04/29/2008, 7:38 AM

I'm a newbie too, but let's say you want to set the default value to today + 1 day in a record or grid field.

=date() + 1 (the '=' is very important)


That seems to work fine. I notice many of the PHP commands and syntaxes are very similar to Access, but I can't seem to get them to work. For example, I'd like to set mine to =Format("y",date()) or =FormatDate(date(),"year") or FormatDate(date(), ["year"]) - those all compile, but then the page fails. Can anyone give a syntax that does work?
_________________
Dave Sause
View profile  Send private message
wkempees
Posted: 05/01/2008, 6:18 AM

Pointing you to:
http://forums.codecharge.com/posts.php?post_id=72064
Walter

"DaveSause" <DaveSause@forum.codecharge> schreef in bericht
news:5481732fbe46cc@news.codecharge.com...
> I'm a newbie too, but let's say you want to set the default value to today
> + 1
> day in a record or grid field.
>
> =date() + 1 (the '=' is very important)
>
>
> That seems to work fine. I notice many of the PHP commands and syntaxes
> are
> very similar to Access, but I can't seem to get them to work. For
> example, I'd
> like to set mine to =Format("y",date()) or =FormatDate(date(),"year") or
> FormatDate(date(), ["year"]) - those all compile, but then the page fails.
> Can
> anyone give a syntax that does work?
> _________________
> Dave Sause
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

jjrjr1


Posts: 942
Posted: 05/02/2008, 10:19 AM

Hi

Here is some code examples in CCS that will get the current date and add days to them and format them using CCS calls.

this gets current date and formats like June1, 2008
$SystemVars["today"]=CCFormatDate(time(),array("mmmm", " ", "d", ", ", "yyyy"));

This code adds 1 days to today's date
$SystemVars["today+15"]=CCFormatDate(time()+(24 * 60 * 60 * 1),array("mmmm", " ", "d", ", ", "yyyy"));


This code adds 15 days to today's date
$SystemVars["today+15"]=CCFormatDate(time()+(24 * 60 * 60 * 15),array("mmmm", " ", "d", ", ", "yyyy"));

This one adds 30 days
$SystemVars["today+30"]=CCFormatDate(time()+(24 * 60 * 60 * 30),array("mmmm", " ", "d", ", ", "yyyy"));

60days
$SystemVars["today+60"]=CCFormatDate(time()+(24 * 60 * 60 * 60),array("mmmm", " ", "d", ", ", "yyyy"));

90 days
$SystemVars["today+90"]=CCFormatDate(time()+(24 * 60 * 60 * 90),array("mmmm", " ", "d", ", ", "yyyy"));

120 days
$SystemVars["today+120"]=CCFormatDate(time()+(24 * 60 * 60 * 120),array("mmmm", " ", "d", ", ", "yyyy"));

Is this the sort of thing you are looking for? I did not quite understand this thread.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.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.