Page 1 of 1

PostPosted: Mon Aug 13, 2007 2:13 pm
by steveK
Hi Dewey and All,

This will be an easy question for you guys: How do I work with dates? For example if I wanted to calculate a person's age via diffdays (today-dateofBirthVar)/365.25 or some such thing (I know that's not the correct syntax). I see from the Help that there's a and there are references to string date(). I don't see in the manual any variable of type "date."

Are dates 'stored' as Strings? as Integers?
What control do I use to call the date picker at run-time? Is it a gadget? Is there a 'sample app' that employs this? I didn't see one in the download package.

Sorry if this is a real no-brainer. If someone can even direct me to the correct portions of the manual, it would be very helpful.

Much thanks. :)

PostPosted: Mon Aug 13, 2007 5:52 pm
by Percival

There is a Date object. See "Library Reference -> System -> Date" in the documentation.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by steveK</i>
<br />
What control do I use to call the date picker at run-time?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Can be found in the help section about the Date object. Use this to display the system date selector dialog.
Code: Select all
bool selectdate(int selby, string title)

Hope this helps.

PostPosted: Tue Aug 14, 2007 3:11 pm
by steveK
Hi Percival,

Thanks, again, for the reply. I actually *did* see
bool selectdate(int selby, string title)
in the manual, but dismissed it thinking it couldn't possibly return a date (given that it's a "boolean" method).

Anyway, I have an OrbForm with a single button. My handler is thus:

//handler push1003.onselect() {
// bool selectdate(int dateDayByMonth, string "mytitle")
I figure I'll get the date picker going, THEN worry about manipulating the date. I'm apparently using the above statement incorrectly, because I keep getting compiler error "error in declaration" at the location between "selectdate" and "(." I've tried pre-declaring the variables and a couple of other permutations, but no luck --- any thoughts?

Much thanks. :) -steve

PostPosted: Tue Aug 14, 2007 3:35 pm
by Percival
Hi again,

How familiar are you with object oriented programming? The selectdate method is from the Date object. Example usage:
Code: Select all
handler push1003.onselect() {
Date date;

date.selectdate(dateDayByMonth, "mytitle");

To manipulate dates, you can assign values to the Date object properties.
Code: Select all
Date date;

date.year = 2007;
date.month = 8; = 14;

PostPosted: Sat Aug 18, 2007 3:13 pm
by steveK
Hi Percival,

I just wanted to say thanks. The sample code works like a charm. I'm not at all experienced with OO programming, though I've read a little about it. I noticed your code contains "date date." I guess this is where the "date object" is declared sort of like a variable is declared. I remember reading in the OrbManual that the OrbRuntime basically treats objects as variables--so this all makes sense. (sort of)

I also found a previous thread that deals with manipulating dates. I'm dissecting that too. Off I go--wish me luck !! :D