Custom Date Format help
-
- Posts: 1
- Joined: Thu Feb 14, 2008 5:03 am
Custom Date Format help
I'm trying to make a custom date format so that only the year is required (YYYY). When I enter this as a user-defined format, the year will not change. No matter what year I enter, it will stay at 1905.
- DrewJensen
- Volunteer
- Posts: 1734
- Joined: Sat Oct 06, 2007 9:01 pm
- Location: Cumberland, MD - USA
Re: Custom Date Format help
There are some database engines ( MySQL being the most prominent of these ) that allow partial dates in a DATE field - the embedded Base database is not one of these.
If you have defined your column type as DATE or DATETIME or TIMESTAMP then a full date must be inserted into the column.
If you want a column that only holds a value representing a year then define it as an INT or CHAR.
Or - use a mask that take takes input for a year part, and automatically adds a month and day for example.
Use a pattern field and an edit mask of something like LLLLLLNNNN then a literal mask of "01/01/____" . With this the user can enter only a valid year.
Later when you use the field in a query simply use the YEAR function to extract this meaningful part
SELECT YEAR( <your date column> ) FROM table
for example.
If you have defined your column type as DATE or DATETIME or TIMESTAMP then a full date must be inserted into the column.
If you want a column that only holds a value representing a year then define it as an INT or CHAR.
Or - use a mask that take takes input for a year part, and automatically adds a month and day for example.
Use a pattern field and an edit mask of something like LLLLLLNNNN then a literal mask of "01/01/____" . With this the user can enter only a valid year.
Later when you use the field in a query simply use the YEAR function to extract this meaningful part
SELECT YEAR( <your date column> ) FROM table
for example.
Former member of The Document Foundation
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04