I am using the dbd function to calculate how many days are between two seperate days, but I don't really understand the syntax of the function. Also, I keep getting a lot of DOMAIN errors, and I don't know what I am doing wrong. Can someone write some examples and maybe possibly convert the number of days between September 9, 2010 - June 5, 2012? Thanks.
dbd( only takes real number values. There are two syntaxes: MM.DDYY and DDMM.YY (the first is for American standards and the second for European). Both take MM between 1 and 12, DD between 1 and 31, and YY between 50 (1950) and 49 (2049). For example, the number of days between September 9, 2010 and June 5, 2012 would be dbd(9.0910,6.0512) (American) or dbd(909.10,506.12) (European).
Deep Thought, aren't you missing some decimal points in those examples in your last sentence? Smile I'm not positive, since I've rarely used dbd().
Right, fail. Sorry.
So how would I cut off the first two numbers of the year? Do I have to store the year as a string, and then use the sub command?
Hm, what do you mean? Like with the number 2012?

Here's an example: Say you have variables M=9, D=9, and Y=2010 (first date), and N=6, E=5, and Z=2012 (second date). To use dbd( with month first, just do dbd(M+sub(D+fPart(sub(Y))),N+sub(D+fPart(sub(Z and it should work.
Deep Thought wrote:
Right, fail. Sorry.
Not a problem; I just wanted to make sure, since I didn't see any other way for the TI-OS to distinguish between the two formats. Smile

Edit: Because I think it might not immediately be apparent, sub(X) = X/100. Sub(1000) is 10 and sub(pi) is 0.031415926...
Yes, I mean converting 2012 to just 12. But the formula that you posted worked out for me. Thanks.

Code:
100fpart(sub(2012
returns 12
kpa, let me explain why that works:

(1) sub(2012) is 20.12
(2) fpart(20.12) = 0.12
(3) 100(0.12) is 12

Voila. Of course, once 9999 rolls over to the year ten thousand, you'll have to update your code. Smile
Ah yeah, forgot to explain why it worked, thanks greatly Kerm Smile
_player1537 wrote:
Ah yeah, forgot to explain why it worked, thanks greatly Kerm Smile
Not a problem. Smile I'm sure your algorithm stood on its own; I just wanted to make sure.
Right, I should probably explain:

M is just left on its own because in the dbd( syntax, M is the integer part anyway. Like June in the above example would be 6.DDYY. D is divided by 100 (in the tenths and hundredths place. YY is divided by 10000, but since you only need the last two digits, you divide it by 100 and take the fPart( to get its lower digits. Now it's already shifted into the 10ths and 100ths place, so all you have to do is divide it by 100 again. sub(, when used with a real number (as opposed to a string, a start value, and a length), divides it by 100 (this is an undocumented feature). So 6+sub(5+fPart(sub(2012 would give you 6+sub(5+fPart(20.12))=6+sub(5+.12)=6+.0512=6.0512, which is what you want for the end date.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement