---
title: "TimeSeriesShift"
language: "en"
type: "Symbol"
summary: "TimeSeriesShift[tseries, shift] shifts the time series tseries to the left or right according to shift."
keywords: 
- time shift
- time series align
- time alignment
- temporal alignment
- shift event series
- shift temporal data
- realign time series
canonical_url: "https://reference.wolfram.com/language/ref/TimeSeriesShift.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Time Series Processing"
    link: "https://reference.wolfram.com/language/guide/TimeSeries.en.md"
related_functions: 
  - 
    title: "MovingMap"
    link: "https://reference.wolfram.com/language/ref/MovingMap.en.md"
  - 
    title: "TimeSeriesAggregate"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesAggregate.en.md"
  - 
    title: "TimeSeriesResample"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesResample.en.md"
  - 
    title: "TimeSeriesThread"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesThread.en.md"
  - 
    title: "RegularlySampledQ"
    link: "https://reference.wolfram.com/language/ref/RegularlySampledQ.en.md"
  - 
    title: "MinimumTimeIncrement"
    link: "https://reference.wolfram.com/language/ref/MinimumTimeIncrement.en.md"
  - 
    title: "TimeSeriesRescale"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesRescale.en.md"
  - 
    title: "TimeSeriesMap"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesMap.en.md"
  - 
    title: "TimeSeriesMapThread"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesMapThread.en.md"
  - 
    title: "TimeSeriesInsert"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesInsert.en.md"
  - 
    title: "TimeSeriesModelFit"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesModelFit.en.md"
  - 
    title: "TimeSeriesWindow"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesWindow.en.md"
  - 
    title: "TemporalData"
    link: "https://reference.wolfram.com/language/ref/TemporalData.en.md"
  - 
    title: "TimeSeries"
    link: "https://reference.wolfram.com/language/ref/TimeSeries.en.md"
  - 
    title: "EventSeries"
    link: "https://reference.wolfram.com/language/ref/EventSeries.en.md"
---
# TimeSeriesShift

TimeSeriesShift[tseries, shift] shifts the time series tseries to the left or right according to shift.

## Details and Options

* ``TimeSeriesShift`` is used to align the start of a time series with a particular time.

* [image]

* The input ``tseries`` can be a list of values ``{x1, x2, …}``, a list of time-value pairs ``{{t1, x1}, {t2, x2}, …}``, a ``TimeSeries``, an ``EventSeries``, or ``TemporalData``.

* Settings for ``shift`` include:

|           |               |
| --------- | ------------- |
| τ         | shift by τ    |
| {k, step} | shift k steps |
| {{tmin}}  | set t1 = tmin |

* The shift ``τ`` can be any real number or a time ``Quantity``.

* For integer ``k``, ``{k}`` is equivalent to giving ``{k, MinimumTimeIncrement[tseries]}``.

* The ``step`` can be a number or date step such as ``"Year"``, ``"Month"``, ``"Day"``, etc.

* ``TimeSeriesShift`` threads over paths for multipath ``TemporalData``.

* ``TimeSeriesShift`` takes the following options:

|                  |                             |                                                 |
| ---------------- | --------------------------- | ----------------------------------------------- |
| CalendarType     | "Gregorian"                 | the calendar system to interpret the dates      |
| HolidayCalendar  | {"UnitedStates", "Default"} | the holiday calendar schedule for business days |
| TimeZone         | Automatic                   | the time zone specification for dates           |

---

## Examples (22)

### Basic Examples (3)

Shift a time series ahead 2.5:

```wl
In[1]:= ts = RandomFunction[ARProcess[{.1}, 1], {1, 10}];

In[2]:= shift = TimeSeriesShift[ts, 2.5];

In[3]:= ListLinePlot[{ts, shift}]

Out[3]= [image]
```

Shift backward 2.5:

```wl
In[4]:= shift = TimeSeriesShift[ts, -2.5];

In[5]:= ListLinePlot[{ts, shift}]

Out[5]= [image]
```

---

Shift a time series ahead 30 days:

```wl
In[1]:= ts = FinancialData["GOOGL", {"January 2012", "January 2013"}];

In[2]:= shift = TimeSeriesShift[ts, {30, "Day"}];

In[3]:= DateListPlot[{ts, shift}]

Out[3]= [image]
```

---

Set the starting time for a time series to 100:

```wl
In[1]:= ts = TimeSeries[Accumulate@RandomReal[{-1, 1}, 100]];

In[2]:= shift = TimeSeriesShift[ts, {{100}}];

In[3]:= ListLinePlot[{ts, shift}]

Out[3]= [image]
```

### Scope (13)

#### Basic Uses (7)

Shift a time series forward by 3.5:

```wl
In[1]:= td = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}];

In[2]:= TimeSeriesShift[td, 3.5]["Path"]

Out[2]= {{4.5, Subscript[x, 1]}, {5.5, Subscript[x, 2]}, {6.5, Subscript[x, 3]}, {7.5, Subscript[x, 4]}, {8.5, Subscript[x, 5]}}
```

---

Shift a time series backward by 3.5:

```wl
In[1]:= td = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}];

In[2]:= TimeSeriesShift[td, -3.5]["Path"]

Out[2]= {{-2.5, Subscript[x, 1]}, {-1.5, Subscript[x, 2]}, {-0.5, Subscript[x, 3]}, {0.5, Subscript[x, 4]}, {1.5, Subscript[x, 5]}}
```

---

Shift by two days:

```wl
In[1]:= td = TimeSeries[Range[5], {"December 29, 2012"}];

In[2]:= shift = TimeSeriesShift[td, Quantity[2, "Days"]];

In[3]:= DateListPlot[{td, shift}]

Out[3]= [image]
```

---

Use business days as an increment:

```wl
In[1]:= td = TimeSeries[Range[5], {"December 29, 2012"}];

In[2]:= shift = TimeSeriesShift[td, {4, "BusinessDay"}];
```

Compare time stamps:

```wl
In[3]:= TimelinePlot[{td["Dates"], shift["Dates"]}]

Out[3]= [image]

In[4]:= DateListPlot[{td, shift}]

Out[4]= [image]
```

---

Shift ahead one week and three days:

```wl
In[1]:=
td = TemporalData[TimeSeries, {{{-0.7300936468626915, -1.4519910060028738, -0.5169470600446475, 
    -0.5865073582473852, -0.3877452738596685, -1.1268832613089939, -1.573832025824792, 
    -1.513287567214887, -0.9281089897453407, -1.51062273515126, -1.1 ... 90256942794819, 
    -0.2908415274027569, -1.1815264644646835}}, 
  {TemporalData`DateSpecification[{2013, 9, 23, 13, 34, 42.7383033}, 
    {2013, 10, 17, 13, 34, 42.7383033}, {1, "Day"}]}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {}}, 
 True, 10.];

In[2]:= shift = TimeSeriesShift[td, {{1, "Week"}, {3, "Day"}}];

In[3]:= DateListPlot[{td, shift}]

Out[3]= [image]
```

---

Shift the start time to 5:

```wl
In[1]:= td = TimeSeries[Accumulate@RandomReal[{-1, 1}, 25], {1}];

In[2]:= shift = TimeSeriesShift[td, {{5}}];

In[3]:= ListLinePlot[{td, shift}]

Out[3]= [image]
```

---

Shift the dates in a time series to begin on today's date:

```wl
In[1]:= td = TimeSeries[Accumulate@RandomReal[{-1, 1}, 25], {DatePlus[DateList[], {-1, "Week"}]}];

In[2]:= shift = TimeSeriesShift[td, {{DateList[]}}];

In[3]:= DateListPlot[{td, shift}]

Out[3]= [image]
```

#### Data Types (6)

Shift the times for a vector forward 2:

```wl
In[1]:= vals = {a, b, c, d, e};

In[2]:= TimeSeriesShift[vals, 2]

Out[2]= {{2, a}, {3, b}, {4, c}, {5, d}, {6, e}}
```

---

Shift the times for a series of time-value pairs backward by 2:

```wl
In[1]:= vals = {{2, a}, {3, b}, {7, c}, {14, d}, {15, e}};

In[2]:= TimeSeriesShift[vals, -1]

Out[2]= {{1, a}, {2, b}, {6, c}, {13, d}, {14, e}}
```

---

Shift the values from a ``TimeSeries`` forward by 10:

```wl
In[1]:= ts = TemporalData[TimeSeries, {CompressedData["«1176»"], {{0, 99, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {}}, False, 10.];

In[2]:= ts1 = TimeSeriesShift[ts, 10]

Out[2]= TemporalData[TimeSeries, {CompressedData["«1174»"], {{10, 109, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {}}, False, 14.3]

In[3]:= ListLinePlot[{ts, ts1}]

Out[3]= [image]
```

---

Shift the values of an ``EventSeries`` forward by 5:

```wl
In[1]:=
es = TemporalData[EventSeries, {{{1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1}}, 
  {{0, 19, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {ResamplingMethod -> None}}, False, 10.];

In[2]:= es1 = TimeSeriesShift[es, 5]

Out[2]=
TemporalData[EventSeries, {{{1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1}}, 
  {{5, 24, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {ResamplingMethod -> None}}, False, 14.3]

In[3]:= ListPlot[{es, es1}, Filling -> Axis]

Out[3]= [image]
```

---

Shift the paths of ``TemporalData`` ahead 10:

```wl
In[1]:= td = RandomFunction[WienerProcess[], {0, 5, 0.1}, 3]

Out[1]=
TemporalData[Automatic, {CompressedData["«1746»"], {{0, 5, 0.1}}, 3, 
  {"Continuous", 3}, {"Continuous", 1}, 1, {ValueDimensions -> 1, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 14.3]

In[2]:= td1 = TimeSeriesShift[td, 10]

Out[2]=
TemporalData[Automatic, {CompressedData["«1746»"], {{10, 15, 0.1}}, 3, 
  {"Continuous", 3}, {"Continuous", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, False, 
 14.3]

In[3]:= Show[ListLinePlot /@ {td["Paths"], td1["Paths"]}, PlotRange -> {{0, 15}, All}]

Out[3]= [image]
```

---

Shift a time series involving quantities:

```wl
In[1]:= ts = TimeSeries[Quantity[{0, 16, 9, 3, 7, 2, 17, 10, 6, 12}, "Meters"]];

In[2]:= ts1 = TimeSeriesShift[ts, 1];

In[3]:= ListLinePlot[{ts, ts1}, PlotLegends -> {"original time series", "shifted time series"}, Filling -> Axis, AxesLabel -> Automatic]

Out[3]= [image]
```

### Options (3)

#### CalendarType (1)

Define a time series:

```wl
In[1]:= data = TimeSeries[{{DateObject[{2016, 11, 10}], 1}, {DateObject[{2016, 11, 14}], 2}, {DateObject[{2016, 11, 15}], 3}}];
```

Shift the data by one day and express the result using the Jewish calendar:

```wl
In[2]:= TimeSeriesShift[data, {1, "Day"}, CalendarType -> "Jewish"]//Normal

Out[2]= {{DateObject[{5777, 8, 10, 0, 0, 0.}, "Instant", "Jewish", -5.], 1}, {DateObject[{5777, 8, 14, 0, 0, 0.}, "Instant", "Jewish", -5.], 2}, {DateObject[{5777, 8, 15, 0, 0, 0.}, "Instant", "Jewish", -5.], 3}}
```

#### HolidayCalendar (2)

Shift a time series by a business day using the default ``HolidayCalendar`` :

```wl
In[1]:= data = TimeSeries[{{DateObject[{2016, 11, 10}], 1}, {DateObject[{2016, 11, 14}], 2}, {DateObject[{2016, 11, 15}], 3}}];

In[2]:= TimeSeriesShift[data, {1, "BusinessDay"}]//Normal

Out[2]= {{DateObject[{2016, 11, 14, 0, 0, 0.}, "Instant", "Gregorian", -5.], 1}, {DateObject[{2016, 11, 15, 0, 0, 0.}, "Instant", "Gregorian", -5.], 2}, {DateObject[{2016, 11, 16, 0, 0, 0.}, "Instant", "Gregorian", -5.], 3}}
```

Use the NYSE holiday calendar:

```wl
In[3]:= TimeSeriesShift[data, {1, "BusinessDay"}, HolidayCalendar -> {"UnitedStates", "NYSE"}]//Normal

Out[3]= {{DateObject[{2016, 11, 11, 0, 0, 0.}, "Instant", "Gregorian", -5.], 1}, {DateObject[{2016, 11, 15, 0, 0, 0.}, "Instant", "Gregorian", -5.], 2}, {DateObject[{2016, 11, 16, 0, 0, 0.}, "Instant", "Gregorian", -5.], 3}}
```

---

Use a holiday calendar of a given country:

```wl
In[1]:= data = TimeSeries[Range[7], {DateObject[{2017, 4, 13}]}];

In[2]:= TimeSeriesShift[data, {1, "BusinessDay"}, HolidayCalendar -> "Germany"]//Normal

Out[2]= {{DateObject[{2017, 4, 18, 0, 0, 0.}, "Instant", "Gregorian", -5.], 1}, {DateObject[{2017, 4, 19, 0, 0, 0.}, "Instant", "Gregorian", -5.], 2}, {DateObject[{2017, 4, 20, 0, 0, 0.}, "Instant", "Gregorian", -5.], 3}, {DateObject[{2017, 4, 21, 0, 0, 0.}, "Instant", "Gregorian", -5.], 4}, {DateObject[{2017, 4, 22, 0, 0, 0.}, "Instant", "Gregorian", -5.], 5}, {DateObject[{2017, 4, 23, 0, 0, 0.}, "Instant", "Gregorian", -5.], 6}, {DateObject[{2017, 4, 24, 0, 0, 0.}, "Instant", "Gregorian", -5.], 7}}

In[3]:= TimeSeriesShift[data, {1, "BusinessDay"}, HolidayCalendar -> "UnitedStates"]//Normal

Out[3]= {{DateObject[{2017, 4, 14, 0, 0, 0.}, "Instant", "Gregorian", -5.], 1}, {DateObject[{2017, 4, 15, 0, 0, 0.}, "Instant", "Gregorian", -5.], 2}, {DateObject[{2017, 4, 16, 0, 0, 0.}, "Instant", "Gregorian", -5.], 3}, {DateObject[{2017, 4, 17, 0, 0, 0.}, "Instant", "Gregorian", -5.], 4}, {DateObject[{2017, 4, 18, 0, 0, 0.}, "Instant", "Gregorian", -5.], 5}, {DateObject[{2017, 4, 19, 0, 0, 0.}, "Instant", "Gregorian", -5.], 6}, {DateObject[{2017, 4, 20, 0, 0, 0.}, "Instant", "Gregorian", -5.], 7}}
```

### Applications (1)

Specify rates for ``TimeValue`` :

```wl
In[1]:=
ts = TemporalData[TimeSeries, {{{0.04, 0.05, 0.06, 0.07, 0.08}}, {{4, 8, 1}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 10.1];
```

Note that the first time step must be 0 to define the initial rate. Shift the time series:

```wl
In[2]:= rates = TimeSeriesShift[ts, {{0}}]

Out[2]=
TemporalData[TimeSeries, {{{0.04, 0.05, 0.06, 0.07, 0.08}}, {{0, 4, 1}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 14.3]
```

Calculate the time value:

```wl
In[3]:= TimeValue[1, rates, 10]

Out[3]= 1.96542
```

### Possible Issues (2)

``TimeSeriesShift`` may break temporal regularity:

```wl
In[1]:= data = TimeSeries[Range[7], {DateObject[{2017, 4, 13}], Automatic, "BusinessDay"}, HolidayCalendar -> "Germany"];
```

Shift by a day:

```wl
In[2]:= ts1 = TimeSeriesShift[data, {1, "Day"}]

Out[2]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 5, 6, 7}}, 
  {{{3701116800, 3701548800, 3701635200, 3701721600, 3701808000, 3702067200, 3702153600}}}, 1, 
  {"Continuous", 1}, {"Discrete", 1}, 1, {HolidayCalendar -> "Germany", 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]

In[3]:= RegularlySampledQ[ts1]

Out[3]= False
```

The next day in Germany is not a business day:

```wl
In[4]:= DayMatchQ[DatePlus[data["FirstDate"], {1, "Day"}], "BusinessDay", HolidayCalendar -> "Germany"]

Out[4]= False
```

Preserve temporal regularity by shifting by a business day:

```wl
In[5]:= ts2 = TimeSeriesShift[data, {1, "BusinessDay"}]

Out[5]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 5, 6, 7}}, 
  {TemporalData`DateSpecification[{2017, 4, 18, 0, 0, 0.}, {2017, 4, 26, 0, 0, 0.}, "BusinessDay", 
    "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {HolidayCalendar -> "Germany", 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]

In[6]:= RegularlySampledQ[ts2]

Out[6]= True
```

Compare the time series:

```wl
In[7]:= DateListPlot[{data, ts1, ts2}, PlotLegends -> {"data", "ts1", "ts2"}]

Out[7]= [image]
```

---

Specifying a new ``HolidayCalendar`` overrides that option in the input:

```wl
In[1]:= data = TimeSeries[Range[7], {DateObject[{2017, 4, 13}], Automatic, "BusinessDay"}, HolidayCalendar -> "UnitedStates"];
```

Shift by one business day with the same ``HolidayCalendar`` :

```wl
In[2]:= res1 = TimeSeriesShift[data, {1, "BusinessDay"}]

Out[2]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 5, 6, 7}}, 
  {TemporalData`DateSpecification[{2017, 4, 14, 0, 0, 0.}, {2017, 4, 24, 0, 0, 0.}, "BusinessDay", 
    "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {HolidayCalendar -> "UnitedStates", 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]
```

Specify a new ``HolidayCalendar`` :

```wl
In[3]:= res2 = TimeSeriesShift[data, {1, "BusinessDay"}, HolidayCalendar -> "Germany"]

Out[3]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 5, 6, 7}}, 
  {TemporalData`DateSpecification[{2017, 4, 18, 0, 0, 0.}, {2017, 4, 26, 0, 0, 0.}, "BusinessDay", 
    "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {HolidayCalendar -> "Germany", 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]

In[4]:= TimelinePlot[{res1["Dates"], res2["Dates"]}, PlotLegends -> Placed[{"United States", "Germany"}, Below]]

Out[4]= [image]
```

## See Also

* [`MovingMap`](https://reference.wolfram.com/language/ref/MovingMap.en.md)
* [`TimeSeriesAggregate`](https://reference.wolfram.com/language/ref/TimeSeriesAggregate.en.md)
* [`TimeSeriesResample`](https://reference.wolfram.com/language/ref/TimeSeriesResample.en.md)
* [`TimeSeriesThread`](https://reference.wolfram.com/language/ref/TimeSeriesThread.en.md)
* [`RegularlySampledQ`](https://reference.wolfram.com/language/ref/RegularlySampledQ.en.md)
* [`MinimumTimeIncrement`](https://reference.wolfram.com/language/ref/MinimumTimeIncrement.en.md)
* [`TimeSeriesRescale`](https://reference.wolfram.com/language/ref/TimeSeriesRescale.en.md)
* [`TimeSeriesMap`](https://reference.wolfram.com/language/ref/TimeSeriesMap.en.md)
* [`TimeSeriesMapThread`](https://reference.wolfram.com/language/ref/TimeSeriesMapThread.en.md)
* [`TimeSeriesInsert`](https://reference.wolfram.com/language/ref/TimeSeriesInsert.en.md)
* [`TimeSeriesModelFit`](https://reference.wolfram.com/language/ref/TimeSeriesModelFit.en.md)
* [`TimeSeriesWindow`](https://reference.wolfram.com/language/ref/TimeSeriesWindow.en.md)
* [`TemporalData`](https://reference.wolfram.com/language/ref/TemporalData.en.md)
* [`TimeSeries`](https://reference.wolfram.com/language/ref/TimeSeries.en.md)
* [`EventSeries`](https://reference.wolfram.com/language/ref/EventSeries.en.md)

## Related Guides

* [Time Series Processing](https://reference.wolfram.com/language/guide/TimeSeries.en.md)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) \| [Updated in 2017 (11.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn112.en.md)