0

I do some research about this topic but i cannot find a solution.

`CreatedDate=models.DateTimeField(auto_now_add=True)`

when i create a model using this code, data type of mssql set as datetimeoffset(7).But i wish to create as type of datetime2(7).

I tried django-mssql-backend library.(It set as datetimeoffset(7)).I was expected datetime2.

https://stackoverflow.com/questions/65600327/sql-datetime27-field-to-django I followed the instructions here but the solution did not work for me

Shortly, how can i create datetime2 with using Django model?

  • It indeed looks like it normally constructs a `datetime2`: https://github.com/microsoft/mssql-django/blob/c0563d3eb85d72ceedcd12b20f4a8b0b039ba2fc/mssql/base.py#L107 – Willem Van Onsem Jul 06 '23 at 13:18

1 Answers1

0

The problem was releated with timezone.To solution:

  • Upload mssql-django
  • Set timezone ( USE_TZ = False ) as false in django settings, model created as datetime2.