# Date being in correct format, ORM says has to be in YYYY-MM-DD format

**URL:** <https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591>\
**Category:** Using the ORM\
**Created:** [October 17, 2023, 2:44pm UTC](https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591 "2023-10-17T14:44:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjanesh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/anjanesh/32/4583_2.png) [@anjanesh](https://forum.djangoproject.com/u/anjanesh)\
**Post date:** [October 17, 2023, 2:44pm UTC](https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591/1 "2023-10-17T14:44:28Z")

</div>

```auto
print("data['attachments']['start'] =", data['attachments']['start']) # 2023-10-18
formatted_start_date = data['attachments']['start']
print("formatted_start_date =",formatted_start_date) # 2023-10-18

soDict = {
        'so_start_date': formatted_start_date,
        'so_end_date': formatted_end_date,
}

print("soDict =", soDict)
so = ServiceOrder(**soDict)
so.save()

```

But I get :

```auto
django.core.exceptions.ValidationError: ['“” value has an invalid date format. It must be in YYYY-MM-DD format.']

```

The model is like this :

```auto
class ServiceOrder(models.Model):
    so_start_date = models.DateField(blank=True, null=True)
    so_end_date = models.DateField(blank=True, null=True)

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 17, 2023, 11:18pm UTC](https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591/2 "2023-10-17T23:18:46Z")

</div>

Unfortunately, your print statement is **not** necessarily showing you the actual format of the data being printed. If `data['attachments']['start']` is an object and not a string, what you are looking at is the output of the ` __str__ ` method of that object. You need to take a closer look at what that data is.

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [October 18, 2023, 10:41am UTC](https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591/3 "2023-10-18T10:41:12Z")

</div>

Hey there, i want to just give a tip on this sintax. It really helps when debugging.

> [@anjanesh](#):
>
> ```auto
> print("data['attachments']['start'] =", data['attachments']['start']) # 2023-10-18
> 
> ```

This can be shortened with the f-string sintax, and will provide the same output.

```auto
print(f"{data['attachments']['start']=}")

```

---

<div class="post-metadata">

**Author:** ![anjanesh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/anjanesh/32/4583_2.png) [@anjanesh](https://forum.djangoproject.com/u/anjanesh)\
**Post date:** [October 20, 2023, 7:22am UTC](https://forum.djangoproject.com/t/date-being-in-correct-format-orm-says-has-to-be-in-yyyy-mm-dd-format/24591/4 "2023-10-20T07:22:07Z")

</div>

I solved this by formatting the date correctly on the browser side of using type=“date”
