Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#9275 closed Uncategorized (fixed)

ORA-01830 date format picture ends before converting entire input... admin

Reported by: hollerith Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Normal Keywords: oracle date formats
Cc: ikelly, mboersma Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Doing: Porting a legacy application on Oracle 10g.
Symptom: The admin change interface reported this error on Datetimefields.
Solution:I found the 'works for me' at least was to alter the NLS_DATE_FORMAT in backend/oracle/base.py to include the time in the correct format to match django format (i.e. no fractions).

Attachments (2)

base.diff (186 bytes) - added by hollerith@… 7 years ago.
basic diff
base.2.diff (186 bytes) - added by hollerith <sp4me4ter@…> 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by hollerith@…

basic diff

Changed 7 years ago by hollerith <sp4me4ter@…>

comment:1 Changed 7 years ago by hollerith <sp4me4ter@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Both files are the same:

429c429
< cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD' "
---

cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' "

comment:2 Changed 7 years ago by mboersma

  • Cc ikelly mboersma added

comment:3 Changed 7 years ago by ikelly

  • Resolution set to fixed
  • Status changed from new to closed

(In [9780]) [1.0.X] Fixed #9275: Extended the Oracle date format to allow DATE columns to be used with DateTimeFields, especially when using legacy databases. Thanks to hollerith for the patch. Backport of [9779] from trunk.

comment:4 Changed 4 years ago by anurag.chourasia@…

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

If the issue still persists and If the model field is a DateTimeField and the Database field is of DATE Type then you could try this to overcome this error

Look for the statement where you are updating the Date field. Over there, replace the microseonds to Zero and Oracle will start treating it gracefully.

For example, if you model field is called date_field

and if you are updating it as

date_field=datetime.datetime.now()

then change it to

date_field=datetime.datetime.now().replace(microsecond=0)

And that will solve the issue

Regards
Guddu

Note: See TracTickets for help on using tickets.
Back to Top