CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Date question

Print topic Send  topic

Author Message
Seppo Apajalahti
Posted: 02/01/2003, 3:54 AM

Hi!

How can I programmatically get date wich is for example ten days after
today. For example today (1.2.2003) I want to that field the value
11.2.2003.

--
Seppo Apajalahti


Tobias Weik
Posted: 02/01/2003, 3:03 PM

Seppo Apajalahti schrieb:
> Hi!
>
> How can I programmatically get date wich is for example ten days after
> today. For example today (1.2.2003) I want to that field the value
> 11.2.2003.

hi seppo,

since I have seen from an older thread, that you are using PHP like me,
here my solution for you:

$myform->datefield->SetValue(strtotime("+10 days"));

you can find more information for setting date-values via the
strtotime-function (included in PHP) here:

http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html

some kind of easy, isn´t it? :))

regards
tobias
Seppo Apajalahti
Posted: 02/01/2003, 10:07 PM


"Tobias Weik" <tw@ccug.de> kirjoitti
viestissä:b1hjo8$upa$1@news.codecharge.com...
> Seppo Apajalahti schrieb:
> > Hi!
> >
> > How can I programmatically get date wich is for example ten days after
> > today. For example today (1.2.2003) I want to that field the value
> > 11.2.2003.
>
> hi seppo,
>
> since I have seen from an older thread, that you are using PHP like me,
> here my solution for you:
>
> $myform->datefield->SetValue(strtotime("+10 days"));
>
> you can find more information for setting date-values via the
> strtotime-function (included in PHP) here:
>
> http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
>
> some kind of easy, isn´t it? :))
>
> regards
> tobias
>
thank you tobias
-Seppo-


Seppo Apajalahti
Posted: 02/02/2003, 9:56 AM


"Tobias Weik" <tw@ccug.de> kirjoitti
viestissä:b1hjo8$upa$1@news.codecharge.com...
> Seppo Apajalahti schrieb:
> > Hi!
> >
> > How can I programmatically get date wich is for example ten days after
> > today. For example today (1.2.2003) I want to that field the value
> > 11.2.2003.
>
> hi seppo,
>
> since I have seen from an older thread, that you are using PHP like me,
> here my solution for you:
>
> $myform->datefield->SetValue(strtotime("+10 days"));
>
> you can find more information for setting date-values via the
> strtotime-function (included in PHP) here:
>
> http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
>
> some kind of easy, isn´t it? :))
>
> regards
> tobias
>
Hi!

I think, that I enjoyed to early. When I used this strtotime function I
could
not resolve the dateformat -problem.

I Try this:
global $testi;
$testi->aika->SetValue(date("d.m.Y")+8);

But anyway, I have problem. I don't know why, but I get as result only 10.02
(today is 02.02.2003). As you see there fails .2003

What shall I try next?

Is that easy - maybe to somebody, but it seems that not for me. But I like
it.

Seppo


Tobias Weik
Posted: 02/02/2003, 12:00 PM

Seppo Apajalahti schrieb:

> I think, that I enjoyed to early. When I used this strtotime function I
> could
> not resolve the dateformat -problem.
>
> I Try this:
> global $testi;
> $testi->aika->SetValue(date("d.m.Y")+8);
>
> But anyway, I have problem. I don't know why, but I get as result only 10.02
> (today is 02.02.2003). As you see there fails .2003
>
> What shall I try next?

Hi Seppo,

sorry, looks like my example was a bit to short :) Okay, here is the
long one:

first of all: DONT use the date() format for SetValue, it wont work! CCS
converts the retrieved value from the db to timestamp, then converts it
to the format you have set at the field-property and then shows it. So
when setting the value via "SetValue", it has to be formatted as
timestamp... it took me about one week, to figure this :)

You have to define at your project settings, how the dateformat should
be formatted by default (for example "dd.mm.yyyy") and also, how it is
stored at your database (for example when using MySQl "yyyy-mm-dd").

Your field "aika" should be set to the data type "date" and the date
format you need (you can type it into the property-tab "format" as
dd.mm.yyyy, your dont have to choose one of the selections!).

Next choose the before-show event and insert your custom code like this:

global $testi;

if(!strlen($testi->aika->Value) && $testi->aika->Value !== false) {
$testi->aika->SetValue(strtotime("+8 days"));
}

I first check, if the field "aika" has retrieved a value from the db or
if it is set to be not displayed and then I insert a default value "+8
days" from now.

You can insert any kind of "spoken" date, like "yesterday", "tomorrow",
"next week", "3 days ago" etc.

This should work... hopefully
Tobias

   


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.