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 -> ASP

 Calculate age

Print topic Send  topic

Author Message
unknownsoul

Posts: 2
Posted: 04/28/2004, 7:04 PM

Hi there.

I need to know how to auto calculate the period of a device used whenever the user change a field of "installed date".

Example:

Date installed : {install_date}
Lifespan : {age}

Whenever the user changes the value in the install_date field, age age field will automatically calculated based on the current date.

Thanks.
_________________

~don't even know thyself~
View profile  Send private message
Mark
Posted: 04/28/2004, 8:29 PM

You could place this in (DateAdd("h","+17", Now)) to your {age} field

That's adding 17 hrs, but you can convert that to months or days
peterr


Posts: 5971
Posted: 04/28/2004, 9:58 PM

In case you want to do this in real-time (as users enter the date) then you may need to use Javascript for tshi. There are many examples on the net:
http://www.google.com/search?q=javascript+calculate+date+age
http://www.google.com/search?q=javascript+calculate+date+age
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
unknownsoul

Posts: 2
Posted: 04/29/2004, 12:36 AM

Thanks guys. Just 1 more question...

How do I do this with codecharge? I mean, how to embed the javascript within asp? Coz I need to insert the calculated age into the database.

I'm a newbie, pls bear with me... :-/
_________________

~don't even know thyself~
View profile  Send private message
peterr


Posts: 5971
Posted: 04/29/2004, 12:51 AM

You can place the JavaScript directly in HTML. Usually those articles that you find on Google will help you understand how to modify the HTML, although you also may need to understand some JavaScript basics. I actually don't know JavaScript but many times I copied some sample JavaScript from other articles into my HTML. Whether you do this in CCS or not, the method is the same.
The JavaScript code should update the value on the page, so that when users submit it, the ASP page will receive it and will record that value in the database. This is exactly the same as if a user entered the value into the field but instead you let JavaScript do this.

An alternative is not to use JavaScript and simply calculate the Age value in ASP after install_date is submitted, as Mark proposed. See:
http://www.google.com/search?q=vbscript+functions+DateAdd
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
desman

Posts: 11
Posted: 04/30/2004, 5:12 AM

Use Marks suggestion, that's all dynamic server side, just remember to quote "" the script in CCS
_________________
ASP.NET man
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.