Gossamer Forum
Home : Products : DBMan : Installation :

How to sort by date

Quote Reply
How to sort by date
I have a calendar database and I want the search results sorted by date and displayed (for example) like this: AUG 16. How do I configure the CFG file and my HTML forms to do this?

Do I need 1 field for the month and one for the day, or do I have to combine month and day into one field?

Thanks.
Quote Reply
Re: [rdavis] How to sort by date In reply to
You can sort by date having both the day, month, and year within one field.

In your .cfg file you would setup up the field for example:

'Date' => [ 8,'date',10,10,0,&get_date,'']

To easily setup your files to use a defined sort order what I do is to define in the .cfg file:

$sort_field ='8'; ### sort order for this database
$sortorder = 'descend'; ### last first


Then in your footer for viewing include for example:

print qq!| <A HREF="$db_script_url?db=profile&uid=$db_uid&view_records=1&$db_key=*&sb=$sort_field&so=$sortorder">List All</A> !;


then you can also add these extra lines to the forms in subs:

sub html_view_search
sub html_view_failure


<input type=hidden name="sb" value="$sort_field">
<input type=hidden name="so" value="$sortorder">


For displaying a partial date please check out this thread reference either here or in the FAQ noted below:


mm/dd/yy format -- yes, it's been covered but i can't get it to work!
jherusalem
05-Nov-2002

In the FAQ it is titled: Displaying partial dates under the "Dates" section

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] How to sort by date In reply to
Many thanks.

Now, forgive me for asking a newbie question. How does the user enter the date? Is it text input?

Also, in your field example...

'Date' => [ 8,'date',10,10,0,&get_date,'']

...does "&get_date " put in the current date? And, then wouldn't my results show the record's date of entry? My database is an events calendar, so I need each record to show the date of the event, not the date of entry.

Thanks, again, for your help.
Quote Reply
Re: [rdavis] How to sort by date In reply to
You are correct, to have them enter the date just leave off the get_date portion of the text field:

'Date' => [ 8,'date',10,10,0,&get_date,'']

making it:

'Date' => [ 8,'date',10,10,0,'','']

You can also put the some defaults so they enter the date according to your format and have the script check it. And you might want to provide an example of the format they should enter in your add form.

You can find some examples of how to designate the format of the dates in the FAQ under the section for "Dates".

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/