> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Manipulating DateTime objects

An essential element of any trader's strategies or indicators is time. You may find yourself wanting a high and low marker for a certain timeframe or you might want something drawn on your charts during those choppy lunch hours. **DateTime** objects are included in the .NET framework, and they can be used to do any time related action, like limiting trading hours or finding the highest high between 9:30AM and 10:30AM.

## Key concepts in this example

* Common manipulation of **DateTime** objects

## Important related documentation

* [DateTime](https://learn.microsoft.com/en-us/dotnet/api/system.datetime)
* [DateTime.Add()](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.add)
* [DateTime.Compare()](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.compare)
* [DateTime.Now](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.now)
* [DateTime.TryParse()](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparse)
* [TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan)
* [DateTime.ToString(string)](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tostring)
* [string.Format()](https://learn.microsoft.com/en-us/dotnet/api/system.string.format)

## Import instructions

1. Download the file contained in this Help Guide topic to your PC desktop.
2. From the Control Center window, select the menu Tools > Import > NinjaScript.
3. Select the downloaded file.

[SampleDateTimeFunctions\_NT8.zip](https://ninjatrader.com/support/helpGuides/nt8/samples/SampleDateTimeFunctions_NT8.zip)