This topic is locked

How to set a shortened date

9/18/2006 8:34:21 AM
PHPRunner General questions
M
mmponline author

Version 3 -

How do I edit my script to get a result in the date field for Month and Year only - na Day (Edit and View and Print pages) If I know where, I would obviously be able to do the Year only as well. If possible, it should be in the templates, to avoid having to do it everytime I build the pages.
Thanks for any help.

R
RickG 9/18/2006

Stephan:

  1. I presume the full date is stored in a table. At what point is it added?
  2. Are you saying you only want to display MMYY on the Edit, View, and print pages?
  3. On the Edit screen, is the field containing the date set to Read Only, or do people need the ability to edit the MM and YY portion, but not the DD ?
    If you could clairfy it would be helpful.

M
mmponline author 9/18/2006

Yes, Only mmyy must be displayed. In other fields only YY.
At the moment, the date facility under add or edit, displays all 3 -DDMMYY. It only needs to have MMYY or YY. The reason for eg. is that a question asks: When did you complete school? Obviously old men like me can only remember the YY and MM. Day is irrelevant for my client in any way.

These changes will be from scratch (adding a new field) or editing. Obviously the dislay in view will be the same.
Hope this helps.

R
RickG 9/18/2006

If Day is irrelevant for my client in any way, would it not be easier to use two small varchar fields, one containing the year values, the other the month values which you can restrict via your own pull-downs? It certainly would ease searching, reporting etc. and you can always concat the two fields when in view or print mode.
It sounds like the field is currently a traditional "date" field which is making things more complicated than it needs to be.

Alexey admin 9/19/2006

Stephan,
the easiest way to do this is to change $locale_info["LOCALE_SSHORTDATE"] variable in locale.php file.

Find this line in include\locale.php file:

function format_number($val)



and insert this one just before:

$locale_info["LOCALE_SSHORTDATE"]="MMyyyy";



Do these changes in Template Editor to avoid modifying files after rebuild.
Set View as type for your field to Short date.

M
mrpeeble 10/15/2007

Stephan,

the easiest way to do this is to change $locale_info["LOCALE_SSHORTDATE"] variable in locale.php file.

Find this line in include\locale.php file:
and insert this one just before:
Do these changes in Template Editor to avoid modifying files after rebuild.
Set View as type for your field to Short date.


Hi,
I modified the template to to $locale_info["LOCALE_SSHORTDATE"]="MMM yyyy";

This gives me a display of 'Aug 2007' very nicely on the list page.
How do I modify advanced search to only search for Month Year?. If I try and leave the day field blank in the search box it does not bring up the required month.

Alexey admin 10/17/2007

I recommend you to not to edit generated files.

Add a calculated field to your SQL query and show it on List and Search pages.

Here is the sample code:

select

...

DATE_FORMAT(DateField, '%b &Y') as Date1,

...



You can find more info on MySQL functions and syntax here:

http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html