Python not formatting inside sqllite3

In my database query which is executed with the sqlite3 module I insert a new row of data which includes a date field.

The problem is when getting todays date with'%Y-%m-%d') which outputs '2023-02-06' (expected output), it changes inside the database to '2015'. Why does this happen?

This is a Django project so that is where i created the model for the database.

class User(models.Model):
    date_joined = models.DateField('%Y-%m-%d')

def add_user(self, email, password):
    date ='%Y-%m-%d')
        INSERT INTO App_user ('username','email','password', 'email_preference', 'region', 'date_joined')
        VALUES ('{username}', '{email}', '{password}', 'All', 'None', {date})

You should not have the date field on the client side when you create the user. This field in Django is automatically saved in the database by defining DateField and registering every user. You can also use the following code snippet to record the user's creation date as well as the date the user updated his profile.

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Back to Top