Start and end date for catalog item

Define multiple catalogs, each with their own custom field types

Moderators: thyon, xtra

Re: Start and end date for catalog item

Postby thyon » Wed Dec 23, 2009 4:17 pm

you could have also created your events using the TL event calendar and used this as a reference link to your DJs, etc. by adding fields for them to the events calendar. Creating your own catalog is really a toss-up between making your own app for TL or using catalog, because if it gets complex, you were better off making your own app, than trying to pigeon-hole the catalog to work for all occasions.
User avatar
thyon
Developer
 
Posts: 722
Joined: Wed Jun 10, 2009 10:02 pm
Location: Cape Town, South Africa

Re: Start and end date for catalog item

Postby valentin » Sun Feb 28, 2010 12:09 am

I´m having a similar problem right now and tried a few things - but without success.

I have a List of Catalog - Items (Simple Table) - Every Item has a Date Field.
Now I want to create a Condition which tells my Modul in the Front End to show only the Items of the present month.

How do I do that?

I tried things like that in the Condition Field:
FROM_UNIXTIME(event_date) = CURMONTH()
(event_date) = CURMONTH()
(event_date) = MONTH()

nothing worked for me. Probably a small thing - maybe somebody knows the right piece of code.
User avatar
valentin
User
 
Posts: 75
Joined: Mon Jul 13, 2009 4:04 pm

Re: Start and end date for catalog item

Postby scare » Mon Mar 01, 2010 8:55 am

Try something like
Code: Select all
MONTH(FROM_UNIXTIME(event_date)) = MONTH(NOW()) AND YEAR(FROM_UNIXTIME(event_date)) = YEAR(NOW())

Although I think that calculating timestamp of the first day in month and first day of the following month and using BETWEEN would be much more efficient :)
S.C.A.R.E
User avatar
scare
User
 
Posts: 61
Joined: Fri Jun 19, 2009 7:19 pm
Location: Kosice, Slovakia

Re: Start and end date for catalog item

Postby valentin » Mon Mar 01, 2010 9:19 am

thanks scare, works like a charme.
Just one question. Does this also show passed event´s of a month?

e.g.: today is the 5th april and there was an event yesterday. will it be displayed? the problem is i´d have to wait untill tomorrow to see what happens - since it´s the frist of march now! ;-)
User avatar
valentin
User
 
Posts: 75
Joined: Mon Jul 13, 2009 4:04 pm

Re: Start and end date for catalog item

Postby scare » Mon Mar 01, 2010 10:24 am

It should display all events from the current month, it ignores the day completely, so only month and year matter. Of course you need to test it :) You may try to substitute NOW() with tomorrow's date to see if today's events are displayed.
S.C.A.R.E
User avatar
scare
User
 
Posts: 61
Joined: Fri Jun 19, 2009 7:19 pm
Location: Kosice, Slovakia

Re: Start and end date for catalog item

Postby valentin » Wed Mar 03, 2010 10:57 am

okay, this works great.
have a look here:
http://grazjazz.at.dd14304.kasserver.co ... sicht.html

can i bother you with another question?
how would i make a list fot the next month? I´m thinking about presenting the present and the coming month...

best regards,
valentin
User avatar
valentin
User
 
Posts: 75
Joined: Mon Jul 13, 2009 4:04 pm

Re: Start and end date for catalog item

Postby scare » Wed Mar 03, 2010 2:05 pm

OK, I'm writing this from my head so don't complain if it doesn't work :) Test every step below in some phpmyadmin or similar program to see if it gives correct results.

We need to find the first day of the next month (should return something like 2010-04-01):
Code: Select all
select DATE_ADD(LAST_DAY(NOW()), INTERVAL 1 DAY)

And the first day of the month following the next month (2010-05-01):
Code: Select all
select DATE_ADD(DATE_ADD(LAST_DAY(NOW()), INTERVAL 1 DAY), INTERVAL 1 MONTH)

Now we just need to select dates between those two dates (+ convert it to unix timestamp), so the result should be something like this:
Code: Select all
event_date >= UNIX_TIMESTAMP(DATE_ADD(LAST_DAY(NOW()), INTERVAL 1 DAY)) AND event_date < DATE_ADD(DATE_ADD(LAST_DAY(NOW()), INTERVAL 1 DAY), INTERVAL 1 MONTH))
S.C.A.R.E
User avatar
scare
User
 
Posts: 61
Joined: Fri Jun 19, 2009 7:19 pm
Location: Kosice, Slovakia

Re: Start and end date for catalog item

Postby valentin » Wed Mar 03, 2010 2:19 pm

thanks, I´ll give it a try - but first I have to solve the problem here:
viewtopic.php?f=27&t=1325
User avatar
valentin
User
 
Posts: 75
Joined: Mon Jul 13, 2009 4:04 pm

Previous

Return to catalog

Who is online

Users browsing this forum: No registered users