selenium-ide: Return month difference - selenium-ide

Given two dates how to return the month difference in IDE?
d1 = (d.getMonth()+1) +'/'+ (d.getFullYear());
d2 = (d.getMonth()+1) +'/'+ (d.getFullYear()+1);
Ex:
Input:
d1 = 5/2013
d2 = 7/2014
Output: (d2-d1) = 14
I tried to use javascript functions from the net but could not get any to work with IDE, tried both ways using function & storeEval.

There are a lot of answers on this question in stackoverflow (e.g. this one ).

Related

extracting date from timestamp in pig

First, I ran this code and it went through. Now, I want to extract only date from timestamp which includes data and time. But, I have no idea how to do it. I used GetYear, GetMonth, GetDay but always an error popped up.
define Quantile datafu.pig.stats.Quantile('21'); data_raw = LOAD 'California/2016/March-2016.csv' USING PigStorage(',') AS (tmc_code:chararray, measurement_tstamp:chararray, speed:int, average_speed:int, reference_speed:int, travel_time_minutes:int,confidence_score:int, cvalue:int);
filtered_data = FILTER data_raw BY confidence_score == 30;
data_reqd = GROUP filtered_data BY (tmc_code, measurement_tstamp);
quantiles = FOREACH data_reqd GENERATE group.tmc_code, ToDate(group.measurement_tstamp,'YYYY-MM-DD HH:mm:ss') AS date, Quantile(filtered_data.speed);
results = Limit quantiles 10;
DUMP results;
I would appreciate it if someone can help me to extract only date from measurement_tstamp.
This is how you could do it
results_new = FOREACH quantiles GENERATE CONCAT(CONCAT(CONCAT((chararray)GetYear(date),'-')),(CONCAT((chararray)GetMonth(date),'-')),(chararray)GetDay(date)) AS Day;
I've answered a similar question here

MATLAB Yahoo Finance fetch gives a bizarre date format

Here's my chunk of code
y = yahoo;
% get some data for Apple
from = '2014-01-01';
to = '2016-04-01';
aapl = fetch(y,'AAPL','Adj Close', from, to);
close(y)
I get two columns - the second are the prices, the first are... Date values? But they cannot be! I expected Unix dates, but my dates start with 1455950 and a conversion gives me:
>> datetime(1455950, 'convertFrom', 'posixtime')
ans =
17-Jan-1970 20:25:50
So that clearly cannot be it. Also, what's crazy is if I get today's date, I get an even smaller value:
>> fetch(y, 'AAPL', 'Date')
ans =
Date: 736449
Can someone help me understand this madnesss?
As it turns out, yahoo was simply giving out false values. All working now, and datetime(x, 'convertfrom', 'datenum') works perfectly as can be seen here.

how to check the date using internet in matlab?

when using date command in matlab, i get the system current date. is there a way to get the current date using internet in matlab? the link i've given is similar to this question but that question was asked for vb, and i'm trying to do this thing in matlab.
https://stackoverflow.com/questions/21198527/how-to-check-the-real-date-time-through-an-internet-connection]
MATLAB Code based on urlread to get current date using internet (URL) and with couple of bounding keys (to find the date string) -
URL = 'http://time.is/';
key1 = 'title="Click for calendar">';
key2 = '</h2>';
data = urlread(URL);
start_ind = strfind(data,key1);
data1 = data(start_ind:end);
off_stop_ind = strfind(data1,key2);
current_date = data(start_ind+ numel(key1):start_ind + off_stop_ind(1)-2)
Output at my location -
current_date =
Saturday, September 6, 2014, week 36
If you would like to have it in the DD-MM-YYYY format, use this -
date_split = strsplit(current_date,',')
current_date1 = datestr(strcat(date_split(2),date_split(3)))
Output -
current_date1 =
06-Sep-2014

Difference in minutes between 2 dates and times?

I need to compute time difference in minutes with four input parameters, DATE_FROM, DATE_TO, TIME_FROM, TIME_TO. And one output parameter DIFF_TIME. I have created a function module, I need to write a formula which computes the time diff in minutes.
Any help would be great!
Thanks,
Sai.
Use CL_ABAP_TSTMP=>TD_SUBTRACT to get the number of seconds between two date/time pairs.
(then, to get the number of minutes, divide the number of seconds by 60).
Example:
DATA(today_date) = CONV d( '20190704' ).
DATA(today_time) = CONV t( '000010' ).
DATA(yesterday_date) = CONV d( '20190703' ).
DATA(yesterday_time) = CONV t( '235950' ).
cl_abap_tstmp=>td_subtract(
EXPORTING
date1 = today_date
time1 = today_time
date2 = yesterday_date
time2 = yesterday_time
IMPORTING
res_secs = DATA(diff) ).
ASSERT diff = 20. " verify expectation or short dump
If the values are guaranteed to be in the same time zone, it's easy enough that you don't need any special function module or utility method. Read this, then get the difference of the dates and multiply that by 24 * 60 and get the difference of the times (which is in seconds) and divide that by 60. Sum it up and there you are.

How to select the last column of numbers from a table created by FoldList in Mathematica

I am new to Mathematica and I am having difficulties with one thing. I have this Table that generates 10 000 times 13 numbers (12 numbers + 1 that is a starting number). I need to create a Histogram from all 10 000 13th numbers. I hope It's quite clear, quite tricky to explain.
This is the table:
F = Table[(Xi = RandomVariate[NormalDistribution[], 12];
Mu = -0.00644131;
Sigma = 0.0562005;
t = 1/12; s = 0.6416;
FoldList[(#1*Exp[(Mu - Sigma^2/2)*t + Sigma*Sqrt[t]*#2]) &, s,
Xi]), {SeedRandom[2]; 10000}]
The result for the following histogram could be a table that will take all the 13th numbers to one table - than It would be quite easy to create an histogram. Maybe with "select"? Or maybe you know other ways to solve this.
You can access different parts of a list using Part or (depending on what parts you need) some of the more specialised commands, such as First, Rest, Most and (the one you need) Last. As noted in comments, Histogram[Last/#F] or Histogram[F[[All,-1]]] will work fine.
Although it wasn't part of your question, I would like to note some things you could do for your specific problem that will speed it up enormously. You are defining Mu, Sigma etc 10,000 times, because they are inside the Table command. You are also recalculating Mu - Sigma^2/2)*t + Sigma*Sqrt[t] 120,000 times, even though it is a constant, because you have it inside the FoldList inside the Table.
On my machine:
F = Table[(Xi = RandomVariate[NormalDistribution[], 12];
Mu = -0.00644131;
Sigma = 0.0562005;
t = 1/12; s = 0.6416;
FoldList[(#1*Exp[(Mu - Sigma^2/2)*t + Sigma*Sqrt[t]*#2]) &, s,
Xi]), {SeedRandom[2]; 10000}]; // Timing
{4.19049, Null}
This alternative is ten times faster:
F = Module[{Xi, beta}, With[{Mu = -0.00644131, Sigma = 0.0562005,
t = 1/12, s = 0.6416},
beta = (Mu - Sigma^2/2)*t + Sigma*Sqrt[t];
Table[(Xi = RandomVariate[NormalDistribution[], 12];
FoldList[(#1*Exp[beta*#2]) &, s, Xi]), {SeedRandom[2];
10000}] ]]; // Timing
{0.403365, Null}
I use With for the local constants and Module for the things that are other redefined within the Table (Xi) or are calculations based on the local constants (beta). This question on the Mathematica StackExchange will help explain when to use Module versus Block versus With. (I encourage you to explore the Mathematica StackExchange further, as this is where most of the Mathematica experts are hanging out now.)
For your specific code, the use of Part isn't really required. Instead of using FoldList, just use Fold. It only retains the final number in the folding, which is identical to the last number in the output of FoldList. So you could try:
FF = Module[{Xi, beta}, With[{Mu = -0.00644131, Sigma = 0.0562005,
t = 1/12, s = 0.6416},
beta = (Mu - Sigma^2/2)*t + Sigma*Sqrt[t];
Table[(Xi = RandomVariate[NormalDistribution[], 12];
Fold[(#1*Exp[beta*#2]) &, s, Xi]), {SeedRandom[2];
10000}] ]];
Histogram[FF]
Calculating FF in this way is even a little faster than the previous version. On my system Timing reports 0.377 seconds - but such a difference from 0.4 seconds is hardly worth worrying about.
Because you are setting the seed with SeedRandom, it is easy to verify that all three code examples produce exactly the same results.
Making my comment an answer:
Histogram[Last /# F]