Metadata Date Field Custom Keywords

Is there a way to print custom date formats from a metadata date field?


So, if I had a date field, could I print using php date keywords: %asset_metadata_myfield_Y% %asset_metadata_myfield_j% etc? What if I wanted to print the year from a date field in two ways, such as 2009 and 09?

[quote]Is there a way to print custom date formats from a metadata date field?


So, if I had a date field, could I print using php date keywords: %asset_metadata_myfield_Y% %asset_metadata_myfield_j% etc? What if I wanted to print the year from a date field in two ways, such as 2009 and 09?[/quote]

Metadata Date fields provide a format to be used as a framework for the data. For example, the date can be stored as "dd/mm/yy" if required.

A UNIX timestamp equivalent is not stored - nor can be inferred from the format in most instances - therefore extraction via keywords is not possible within Matrix.



The only potential solution would be to tokenise on "-" and ":" characters with Javascript (presuming it's an ISO 8601 date - ie; "Y-m-d H:i:s") to extract the required data.



Edit: Fixed up PHP date format example

[quote]Metadata Date fields provide a format to be used as a framework for the data. For example, the date can be stored as "dd/mm/yy" if required.
A UNIX timestamp equivalent is not stored - nor can be inferred from the format in most instances - therefore extraction via keywords is not possible within Matrix.



The only potential solution would be to tokenise on "-" and ":" characters with Javascript (presuming it's an ISO 8601 date - ie; "Y-m-d H:i:s") to extract the required data.



Edit: Fixed up PHP date format example[/quote]



I see. Well, I think the JS option will be what I have to do, but I think it will work well.



Could you explain why the storage of dates for metadata date fields and calendar items are different, and the reasons? I love being able to print any time format with the php date keywords for calendars.



Thanks.

The reason is that metadata stores text-based data only as it was not originally designed to do what attributes can do. It just turned out that way.


Calendar is data-specific and so has it's own table so it can perform date manipulation fast.

[quote]The reason is that metadata stores text-based data only as it was not originally designed to do what attributes can do. It just turned out that way.


Calendar is data-specific and so has it's own table so it can perform date manipulation fast.[/quote]





I guess this explains why when I sort by metadata date ascending it make april the first date and september the last (ie it is actually sorting alphabetically on the name of the month)



AAAARGhh!!!!

[quote]I guess this explains why when I sort by metadata date ascending it make april the first date and september the last (ie it is actually sorting alphabetically on the name of the month)


AAAARGhh!!!![/quote]



We added an option to sort by presentation or raw data for this reason. If you sort by the raw value, you will get your assets in date order.

[quote]I guess this explains why when I sort by metadata date ascending it make april the first date and september the last (ie it is actually sorting alphabetically on the name of the month)


AAAARGhh!!!![/quote]



You should be able to sort by raw metadata value, which would give you the correct sort order.



Cept we is currently running version 3.14.3 which does not support this option.....

...more compelling reasons to upgrade


thanks fer yr help anyways


cheers Mat

I have a similar scenario where I'm wanting to display a list of PDF assets grouped by month. In the Metaschema used for the PDFs, I use a Metadata Date Field where date, month and year are selected, and have set the Display Format to 'F' so that I can sort the PDFs by month in the Asset Listing Page. The problem I have is as follows: if the Default Metadata Sort Type is Presentation Value, and I use %group_name% to display the group headings, it groups the PDFs nicely under the correct month assigned to the PDF, but the month headings are listed alphabetically. If I then change the Default Metadata Sort Type to the Raw Value, the %group_name% no longer displays the name of the month: instead it displays as YYYY-MM-DD, and instead of grouping the PDFs by month, it groups them by the date. The only positive thing that happens is that the date headings sort chronologically. Any ideas on this? I would have hoped that regardless of sorting by Presentation Value or Raw Value, the Display Format would remain constant.