Hi All.
I have form with two date field. The field EffectDate used to enter random date and second is ExpDate to get date on one year late. How to get correct date on ExpDate field if differeence between dates possible 365 or 366 days. I will appreciate for brief explaination with sample.
Thanks.
Views
Replies
Total Likes
I have a sample that shows the technique using FormCalc. Note that Date manipulation is much easier in FormCalc than in Javascript.
Paul
Views
Replies
Total Likes
Hi Paul.
Thanks for replay.How to get correct date if difference between dates is 366 days?
Thanks.
Views
Replies
Total Likes
You can see in the sample that the current date must be changed in to a format where we can do Date arithmetic. So the Date2Num function turns the date into th enumber of milliseconds from a point in time (called an epoch). Then we can add the 365 * 24*60* 60 milliseconds to the number. Now we can use the Num2Date function to get a date back.
paul
Views
Replies
Total Likes
Hi Paul,
I modified code
TextField1.rawValue = TextField1.rawValue + 365
to
TextField1.rawValue = TextField1.rawValue + 365 * 24 * 60 * 60
I enter in EffectDate 08/30/2010 and get in ExpDate field wrong date like 4/19/8353. How to fix it? How to make ExpDate field empty if EffecDate is empty?
Thanks.
Views
Replies
Total Likes
You cannot just add numbers to a date ...it makes no sense. If you look at the sample I sent you on the Button click event there is code that will change the date to the number of milliseconds from the epoch. Then you can add your 365 days....then you will need to turn the number back to a date before displaying it.
Paul
Views
Replies
Total Likes
Hi Pual, Thanks for your replays.
I'm thinking for that calculation need to insert logic code. What I mean. If we check number of days in a year we will know that year is leap year or not. And then to perform some math operation. Can you show how it to do in my case?
Thanks.
Views
Replies
Total Likes
If you are going to simply add a year to the current date then why does it matter whether it is a leap year or not. If you add 1 year to Aug 30, 2010 then shoudln't it be Aug 30, 2011?
Paul
Views
Replies
Total Likes
Hi Paul,
If we have a deal with Aug 30, 2010 and Aug 30, 2011 then difference 365 days and you are right. But what about Aug 30, 2011 and Aug 30, 2012. In that case difference is 366 days. Because in February 2012 has 29 days and February 2011 has 28 days. That is problem. If you know how it fix I will appreciate you.
Thanks.
Views
Replies
Total Likes
So why not just add one to the year ...we can break the date into component parts and get the year back then add 1 and then reassemble the date
. Does that make sense? So whether it is a leap year or not the correct answer will always be the same date (Aug 30) + the year + 1.....makes sense?
Paul
Views
Replies
Total Likes
I figured a sampel woudl be easier to explain ....have a look at the code in the add 1 year button.
paul
Views
Replies
Total Likes
That is exactly what I said early. We need a logic statment to check amount of days in a year and if leap year add 366 if not so add 365.
Thanks.
Views
Replies
Total Likes
If you break the date apart then adding 1 to the year should be all we need to do.
Paul
Views
Replies
Total Likes
Hi Paul,
Is it possible to format date field to MM/DD/YYYY? If yes, how to do?
Thanks.
Views
Replies
Total Likes
In the Date field on the Object palette - select the Value tab and click on the Validation Pattern tab. Now click on the Display tab and choose the appropriate style that you want. You shoudl end with a pattern that looks like this:
date{MM/DD/YYYY}
Note that you will have to change the code from the other sample as it uses a different format.
Paul
Views
Replies
Total Likes
I know yet how to change date format for object. Can you suggest how to change the code to get correct result?
Thanks.
Views
Replies
Total Likes
Here is an updated sample.
Paul
How to set up tool tip if type value of EndDate field is Read Only.
Thanks.
Views
Replies
Total Likes
The tooltips will only come up in a field where you can enter data into the field. A readOnly field does not allow that so the tooltip will not show.
Paul
Views
Replies
Total Likes
How to remove any tooltip if field is Read Only? Now the tooltip of read only field display like form1[0].#subform[0].EndDate[0]. How to remove it?
Thanks.
Views
Replies
Total Likes
If the field is readOnly then the tooltip will not display ....are you seeing a tooltip on a ReadOnly field? The cursor shoudl stay as a hand and the field cannot be selected. Are you seeing different behaviour?
Paul
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies