Hello ! please i need help. i want to extract a date from create_date field in odoo. ex :
when i did this. i got error.
record.create_date.date()
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello ! please i need help. i want to extract a date from create_date field in odoo. ex :
when i did this. i got error.
record.create_date.date()
When you create any record, the create_date field remains empty and contains the False value. You must need to save your record before accessing Date from the create_date field.
Then you can get date from record.create_date.date().
Thanks very much for ur effort. but in my case, i want to compare two dates. one of them is datetime field witch is create_date. so i want to get a date from datetime field. that is a real problem. if some one can hep me, how to get generally, date from datetime field knowing that i use odoo online.
when i try this for example:
d = datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").date()
and
d = datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").strftime('%Y-%m-%d')
gives me an error.
Regards !!
You can extract Date from the DateTime type field by
create_date.date(). This will give you only date from datetime field.
If you are comparing two dates then those two date need to be present there. If you accessing create_date, record must be saved first.
record.create_date.date() return 'NONE'
if you are trying to set date before saving the record in database it will return empty value(bool) for create_date field.
You can share your code for more assistance :)
Thanks very much for ur effort. but in my case, i want to compare two dates. one of them is datetime field witch is create_date. so i want to get a date from datetime field. that is a real problem. if some one can hep me, how to get generally, date from datetime field knowing that i use odoo online.
when i try this for example:
d = datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").date()
and
d = datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").strftime('%Y-%m-%d')
gives me an error.
Regards !!
You can extract date from create_date by record.create_date.date(),
but you are trying to get this value before saving the record, so the date value can't be extracted from an empty field.
make sure the record is saved first then you can compare two dates
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Hi,
Can You please share your error?
regards