> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/17.latest/model-your-content/property-editors/built-in-umbraco-property-editors/date-time-editor/date-only.md).

# Date Only

`Schema Alias: Umbraco.DateOnly`

`UI Alias: Umb.PropertyEditorUi.DateOnlyPicker`

`Returns: DateOnly?`

The Date Only property editor provides an interface for selecting dates without including time or time zone information. It focuses purely on date selection and returns a `DateOnly` value.

## Configuration

You can configure this property editor in the same way as any standard property editor, using the *Data Types* admin interface.

To set up a property using this editor, create a new *Data Type* and select **Date Only** from the list of available property editors.

This editor has no configuration options.

## Editing experience

### Adding or editing a value

You will be presented with a date input.

![Date Only property editor interface](/files/GFQ84fBF8gycahM1gfIq)

## Rendering

The value returned will have the type `DateOnly?`.

### Display the value

With Models Builder:

```csharp
@Model.EventDate
```

Without Models Builder:

```csharp
@Model.Value<DateOnly?>("eventDate")
```

## Add values programmatically

This property editor stores values as a JSON object. The object contains the date as an ISO 8601 string with midnight time and UTC offset.

### Storage format

The property editor stores values in this JSON format:

```json
{
    "date": "2025-01-01T00:00:00+00:00"
}
```

The property editor handles date-only values. Time is set to 00:00:00 and offset to +00:00 for storage consistency. These time components are ignored in the Date Only context.

1. Create a C# model that matches the JSON schema.

   ```csharp
   using System.Text.Json.Serialization;

   namespace UmbracoProject;

   public class DateOnlyValue
   {
       /// <summary>
       /// The date value, represented as a <see cref="DateTimeOffset"/> for storage compatibility.
       /// </summary>
       [JsonPropertyName("date")]
       public DateTimeOffset Date { get; init; }
   }
   ```
2. Convert your existing date value to `DateTimeOffset` for storage.

   If you have a `DateOnly`:

   ```csharp
   DateOnly dateOnly = DateOnly.FromDateTime(DateTime.Today); // Your existing DateOnly value
   DateTimeOffset dateTimeOffset = dateOnly.ToDateTime(TimeOnly.MinValue);
   ```

   If you have a `DateTime`:

   ```csharp
   DateTime dateTime = DateTime.Today; // Your existing DateTime value
   DateOnly dateOnly = DateOnly.FromDateTime(dateTime);
   DateTimeOffset dateTimeOffset = dateOnly.ToDateTime(TimeOnly.MinValue);
   ```
3. Create an instance of the class with the `DateTimeOffset` value.

   ```csharp
   DateOnlyValue value = new DateOnlyValue
   {
       Date = dateTimeOffset
   };
   ```
4. Inject the `IJsonSerializer` and use it to serialize the object.

   ```csharp
   string jsonValue = _jsonSerializer.Serialize(value);
   ```
5. Inject the `IContentService` to retrieve and update the value of a property of the desired content item.

   ```csharp
   IContent content = _contentService.GetById(contentKey) ?? throw new Exception("Content not found");

   // Set the value of the property with alias 'eventDate'. 
   content.SetValue("eventDate", jsonValue);

   // Save the change
   _contentService.Save(content);
   ```

### Getting values programmatically

For an example on how to work with `DateOnly` property using `IContentService` see the [Getting date values programmatically](/umbraco-cms/17.latest/extend-your-project/server-side-extensions/management/using-services/contentservice.md#getting-date-values-programmatically) article.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-cms/17.latest/model-your-content/property-editors/built-in-umbraco-property-editors/date-time-editor/date-only.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
