DTTOIDX

Purpose:

Converts date and time values to series indices.

Syntax:

DTTOIDX(series, date, time, "timezone")

series

-

A series, the input series.

date

-

A string or series of Julian integer dates, the input date. Defaults to the current date.

time

-

 A string or series of time of day values, the input time. Defaults to the current time.

"timezone"

-

Optional. A string, the local time zone. Defaults to the current time zone. If specified, the resulting timestamps are based on UTC time.

 

Alternate Syntax:

DTTOIDX(series, datetime, "timezone")

series

-

A series, the input series.

datetime

-

An array, a datetime series where the date and time values are in adjacent columns.

"timezone"

-

Optional. A string, the local time zone. Defaults to the current time zone. If specified, the resulting timestamps are based on UTC time.

Returns:

A series of integer indices.

Example:

W1: gnorm(10, 1);setdate(w0, "1/1/2030");settime(w0, "12:00:00")

W2: {julstr("1/1/2030"), julstr("1/1/2030"), julstr("1/1/2030")};setvunits("Date");table

W3: {todstr("12:00:00"), todstr("12:00:04"), todstr("12:00:09")};setvunits("Time");table

W4: dttoidx(w1, w2, w3)

 

W1 contains the input data.

 

W2 contains a date series.

 

W3 contains a time series

 

W4 returns the indices {1, 5, 10} of W1 using the date values in W2 and the time values in W3

Example:

W1: gnorm(10, 1);setdate(w0, "1-1-2030");settime(w0, "12:00:00")

W2: idxtodt(w1, {1, 5, 10});table

W3: dttoidx(w1, w2)

 

W2 returns the date/time values of W1 using the indices {1, 5, 10}.

 

W3 returns the indices {1, 5, 10} from the date/time values in W1.

Example:

W1: randn(1000, 3);setdate(w0, "1-1-2030");settime(w0, "12:00:00");setdeltax(1, 1);setdeltax(10, 2);setdeltax(100, 3)

W2: extract(W1, 200, 100);setdate(getdate(w1));settime(gettime(w1))

W3: getdt(w2)

W4: dttoidx(w1, w3)

 

W1 contains 3 series each with a different DELTAX. All columns have the same start date and start time.

 

W2 extracts 100 values from each column of W1 starting at index 200. The date and time for each column is set to the same date and time value of W1.

 

W3 contains the date time values of the extracted data. Note the time values are different for each column due to the differing sample spacing.

 

W4 converts the date time values in W3 to the corresponding index values of W1. Each column contains the indices 200..299, matching the original extraction range specified in W2.

Remarks:

DTTOIDX converts the date and time values of an input series to the equivalent indices based on the start date and start time of the series.

 

See IDXTODT to convert indices to date/time values.

 

See DTTOX to convert series X values to date time values.

See Also:

DATE2DT

DT2YMDHMS

DT2TIMESTAMP

DTTOX

GETDT

IDXTODT

IDXTOX

XTODT

XTOIDX