Posted by Zythyr on June 27, 2009 at 6:30am
I have been trying to do this for ever now, but can't get it to work. I want to create a field where users input the year in the standard 4 digit format. For example: 2004. The vaild years any year up to the present year, 2009.
In order to do this, I created a Integer- Text Field. But the problem I was having with this was that it wouldn't let me set the maximum characters to 4 digits.
Then i installed the date.module. Using the Date field type, I finally got it to work. But the output always came out like this "YYYY - YYYY". So if the user put in the value of 2005, the output comes out to "2005 - 2005." Why is it doing this?
Comments
=-=
use the date.module which exposes date fields.
Thats what I did, read my
Thats what I did, read my post above...I used the date.module but the problem I am having is that the output always came out like this "YYYY - YYYY". So if the user put in the value of 2005, the output comes out to "2005 - 2005." Why is it doing this?
=-=
Heh, I guess i never finished my thought.
could you further explain the steps you took to add the field?
Did you set up a custom date display in administer -> date tools?
If I can reproduce the problem, we can work toward an answer or file a bug report. If I can't reproduce the problem we can compare versions of the date module in use. Though for the record I use the latest -dev release.
Okay this what I am trying to
Okay this what I am trying to achieve. I am trying to have users type in the semester of a class. The semester consist of two parts, the term, and the year. The term could be for example, Fall, and the year could be for example 2008. Since this can't be done with just one field, I broke it up into two different field. The first field is for the terms, which I just created a regular Text- Select List field.
The problem I am having is with the year field. I want to make sure that users are only putting the years in the 4 digit format, and that the year can be anywhere from the past to the present year 2009.
I installed the date.module. Then I went to the content type I am creating and did the following.
1) I created a new field, Type: Date Operation: text field with custom input format
2) Below are the settings I used
Default Value: Now
Default value for To date: Same as From Date
Custom Input Format: Y
Customized Date Parts: None
To Date: Never
Granularity: Year (only year selected)
Default Display: Medium
Time Zone Handeling: No time zone conversion
I used those settings above. Created a sample content and put the value of "2005" for the year. Once I saved it, the output was 2005 - 2005.
Once thing I noticed in the settings was it was asking something about "to" and "from" date. Maybe this could be causing the problem. Why is it asking this? WHy can't I just have a regular date.
=-=
I believe you must set up a custom date format.
in adminsiter -> date tools
you can set up a date format that includes only the year
then use this new format in your date field.
For example: there are times when I want to display 'only time'
I create a new date format which will display 'only time'
and in default display i can choose 'only time'
Its still not working. I used
Its still not working. I used the Date Tools wizard to create the year field. It not only created the Year field, but it also created the content type (which I didn't want).
Anyways, it still outputs the year in the YYYY - YYYY. For some reason it thinks that I want 2 years, a "from year" and a "to year"
=-=
I wouldn't have used the date tools wizard. I would have simply create a date format.
however, your issue is sounding more like an issue for the date.module issue queue.
I got it fixed. Apparently
I got it fixed. Apparently there was a problem with the current install of my drupal. I am guessing it was flooded with too many modules and stuff which I was testing. I created a new install of Drupal and installed the Date module again. It worked fine.