Hello, I need to make automatic monthly numbering. The field available in the system only supports annual. There is often a need to use the monthly one, I tried using SQL fields but it didn't work. Does anyone know a way or is there any plans to do so? That is, records related to the indicated date field numbered ascending and reset to zero for each month separately.
It is important that it is a date field, any date, and not e.g. the date of record creation.
Monthly numbering automatic
-
- Posts: 651
- Joined: 30 Oct 2017, 11:24
- Name: Enis Hemedoglu
- Location: Istanbul, Turkey
- Company Name: SCORE DANISMANLIK
- Contact:
Re: Monthly numbering automatic
The following code should work.
Create a numeric field. [1112]
Create a date field. [1111]
Create a numeric field. [1112]
Create a date field. [1111]
Code: Select all
$item_month = date('Y-m', [1111]); //change Unix time to Y-m format
$info_query = db_query("select field_1112 as num, from_unixtime(field_1111, '%Y-%m') as month from app_entity_28 order by id desc limit 1,1");
$info = db_fetch_array($info_query);
$prev_item_num = $info['num']; //previous item number
$prev_item_month = $info['month']; //previous item month
//assign the new auto number
if($item_month == $prev_item_month)
{
$new_item_num = $prev_item_num + 1;
}
else
{
$new_item_num = 1;
}
//save the new auto number to db
$output_value = $new_item_num;
Re: Monthly numbering automatic
How to assign a calculated value from the given code to a numeric field?
-
- Posts: 651
- Joined: 30 Oct 2017, 11:24
- Name: Enis Hemedoglu
- Location: Istanbul, Turkey
- Company Name: SCORE DANISMANLIK
- Contact:
Re: Monthly numbering automatic
Re: Monthly numbering automatic
It doesn't work, what type of field should I use for calculations?
Re: Monthly numbering automatic
I always get the value 1 in the numeric field of subsequent items. Not another value, increased by 1.
Re: Monthly numbering automatic
And it doesn't transfer anything to the numeric field.