AFL reference for Date calculations

#2
Do you need it for exploration?

Code:
cDate = ParamDate( "Choose Date", "2012-02-27" );
cond =  IIf(DateNum() == cDate , DayOfWeek(), Null );
SetOption("Nodefaultcolumns", 1);
Filter = Cond;

AddColumn(DateTime(), "Custom Date", formatDateTime);
AddColumn(DayOfWeek(), "Weekday", 1);
 
#4
Thanks dtwo
but its not what iam looking for ,,

i need day of week for any gvn date,,
Are you kidding me????

You wrote "of a particular date". Do you know what ParamDate means?

Gtfo and do it yourself, Prince IChangeMyMindEverySecond! I'm not here to waste time for free.
 
#7
ParamDate let's you choose the particular date via Parameter dialog. As this is a code for exploration the Parameter dialog needs to be opened in AA window instead of chart pane.

What paramdate does is explained in the help file

SYNTAX ParamDate( ''Name'', ''Default date'', format = 0 );
RETURNS NUMBER or STRING
FUNCTION Adds a new user-definable date parameter, which will be accessible via Parameters dialog :
right click over chart pane and select "Parameters" or press Ctrl+R allows to change chart parameters - changes are reflected immediatelly.

"name" - defines parameter name that will be displayed in the parameters dialog
"default date" - is a string holding date in any any format: YYYY-MM-DD, MM/DD/YY, DD-MM-YY, etc, etc.
format - defines return value format, allowable values are:
0 - return value is a NUMBER and holds DateNum. Ie: 990503 for May 3, 1999,
1 - return value is a STRING formatted holding date according to your windows regional settings

WARNING: default parameter has to be CONSTANT. This is because these values are cached and are not re-read during subsequent formula evaluations.

EXAMPLE start = ParamDate( "Start Date", "2003-05-03" );
So the cond says: if the datenum of your history is equal to the chosen paramdate then output is dayofweek otherwise it's Null.
 
#9
Sorry but there are calendars on the net that show the expiry dates.

Do you wanna know how many days till expiry?

Code:
cDate = 1120301;
add = DateTimeDiff( DateTimeConvert(2,  Cdate), Now(5))/3600/24;
printf("" + NumToStr(add, 1.2) + " days from now till expiry\n"  );
 

Similar threads