[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] re: Count calendar days



PureBytes Links

Trading Reference Links



 Months should be numbered started from 0 to 11 (not 1 to 12 as I thought),
because JScript Date treats 11 as december and 0 as january.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
Sent: Wednesday, October 21, 2009 7:20 PM
Subject: Re: [amibroker] re: Count calendar days

Tomasz
I changed the last line to
"Calendar days from today till November 8th, 2009 = " + sc.GetDaysTill( 2009, 11, 8 );

and it returned 47
By the calendar it is only 18, not counting today.

Also fiddled and found out that if you insert a date in the past, the function gives negative values - also not what I expected
For example putting in 2009,8,11 gives -41 but actually the number is (-) 74.

What am I doing wrong?
 
Best Regards
Rick Osborn



From: Tomasz Janeczko <groups@xxxxxxxxxxxxx>
To: amibroker@xxxxxxxxxxxxxxx
Sent: Wed, October 21, 2009 11:50:46 AM
Subject: Re: [amibroker] re: Count calendar days

 

Hello,

Sorry, I was writing from memory and forgot that DaysSince1900 does not take arguments therefore can not be used for that purpose.

Instead use this:

EnableScript( "JScript" );
<%
function GetDaysTill( y, m, d )
{
msecPerDay = 1000 * 60 * 60 * 24;

dt = new Date( y, m, d, 0, 0, 0 );
today = new Date();

distance = dt.getTime() - today.getTime( );

return Math.floor( distance / msecPerDay );
}
%>

sc = GetScriptObject( );

"Calendar days from today till January 1st, 2010 = " + sc.GetDaysTill( 2010, 1, 1 );

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "sebastiandanconia" <sebastiandanconia@ yahoo.com>
To: <amibroker@xxxxxxxxx ps.com>
Sent: Wednesday, October 21, 2009 5:21 PM
Subject: [amibroker] re: Count calendar days

> (response got mixed up with different poster)
>
> Tomasz said: "You can use DateTimeConvert in conjunction with DaysSince1900. First one will convert from string representing
> date to datetime format and second one will report number of days. By subtracting this and DaysSince1900 of today you will get
> number of calendar days till future date."
>
> Tomasz, you've never yet let me down.:) I'll give that a whirl and post the code when I get it puzzled out.
>
>
> Sebastian
>
>
>
> ------------ --------- --------- ------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroke r.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroke r.com/devlog/
>
> Yahoo! Groups Links
>
>
>



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___