RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • calendarDuration
    • dateshift
    • datetime
    • day
    • duration
    • hour
    • minute
    • month
    • second
    • year

dateshift — Shift datetime values to calendar boundaries or weekday occurrences.

dateshift implements the public start, end, and day-of-week forms with singular calendar units and optional current, next, previous, nearest, or integer occurrence rules. Week calculations begin on Sunday. Weekday indices and integer rules are read from authoritative integer storage before calendar evaluation.

Syntax

t2 = dateshift(t, boundary, unit)
t2 = dateshift(t, boundary, unit, rule)
t2 = dateshift(t, "dayofweek", weekday)

Inputs

NameTypeRequiredDefaultDescription
tAnyYes—Datetime input.
boundaryStringScalarYes—Shift form: 'start', 'end', or 'dayofweek'.
unitStringScalarYes—Calendar/time unit.
ruleAnyNo—Optional current/next/previous/nearest or integer occurrence rule.

Returns

NameTypeDescription
tAnyDatetime object result.

Errors

IdentifierWhenMessage
RunMat:datetime:InvalidArgumentArguments or option grammar do not match supported datetime forms.datetime: invalid argument
RunMat:datetime:InvalidInputInput values cannot be parsed/converted/broadcast to a valid datetime result.datetime: invalid input
RunMat:datetime:InternalInternal datetime state or indexing/evaluation failed unexpectedly.datetime: internal operation failed

How dateshift works

  • dateshift(t, 'start', unit) and dateshift(t, 'end', unit) default to the current unit. Supported singular units are year, quarter, month, week, day, hour, minute, and second.
  • The end of a year, quarter, month, or week is midnight at the beginning of its last day. The end of a day, hour, minute, or second is exactly the start of the next unit.
  • dateshift(t, 'dayofweek', dow) accepts weekday names or numeric indices from 1 for Sunday through 7 for Saturday. weekday and weekend select the corresponding day groups.
  • Rules can be current, next, previous, nearest, or integer scalar/arrays. Datetime, weekday, and rule arrays must have matching sizes or be scalar; scalar expansion preserves the non-scalar input shape.
  • Plural unit aliases, nearest as a boundary token, and a custom week-start argument are rejected because they are not part of this public contract.
  • There is no resident datetime output. Resident arguments are accepted only through the declared RunMat extension and are gathered to a host result.

Does RunMat run dateshift on the GPU?

No GPU kernel is dispatched. MATLAB-compatible mode rejects resident arguments before provider access; RunMat extension mode gathers them and returns a host object.

GPU memory and residency

No. Inputs and outputs are host datetime objects. A compatibility-gated resident input is gathered before calendar evaluation.

Examples

Shift to the Sunday at the start of the current week

dateshift(datetime(2024, 3, 14), 'start', 'week')

Expected output:

ans =
  10-Mar-2024

Shift to the next Monday occurrence

dateshift(datetime(2024, 3, 14), 'dayofweek', 'Monday')

Expected output:

ans =
  18-Mar-2024

Shift to the end of the current month

dateshift(datetime(2024, 2, 10), 'end', 'month')

Expected output:

ans =
  29-Feb-2024

Using dateshift with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how dateshift changes the result.

Run a small dateshift example, explain the result, then change one input and compare the output.

FAQ

When does a week begin?⌄

Sunday, matching the compatibility contract used by MATLAB calendar weeks.

Does end of month mean the last millisecond?⌄

No. For month, quarter, year, and week, it is midnight at the beginning of the final calendar day.

Related Datetime functions

calendarDuration · datetime · day · duration · hour · minute · month · second · year

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how dateshift is executed, line by line, in Rust.

  • View the source for dateshift in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How dateshift works
  • Does RunMat run dateshift on the GPU?
  • GPU memory and residency
  • Examples
  • Shift to the Sunday at the start of the current week
  • Shift to the next Monday occurrence
  • Shift to the end of the current month
  • Using dateshift with coding agents
  • FAQ
  • Related Datetime functions
  • Open-source implementation
  • About RunMat