June 2, 2009 at 1:54 am
Hi,
I have the following problem. I have a table with news-items with a start- and end-date.
Now I only wnat to show items that are between these to dates.
How do I have to do that.
I thought it had to be something like this.
Select * from tbl_nieuws where date(now) between start_date and end_date
This however doesn't work.
I hope someone can help me.
Kind regards,
Martin Smits
June 2, 2009 at 2:02 am
Try GETDATE()
insted of date(now)
If that doesn't work, post the error you are getting.
June 2, 2009 at 2:09 am
info (6/2/2009)
I have a table with news-items with a start- and end-date.
Hi,
Can you show the table schema with data?
ARUN SAS
June 2, 2009 at 2:48 am
Here you are
id bigint(11) Nee auto_increment
titel text utf8_unicode_ci Ja NULL
introductie longtext utf8_unicode_ci Ja NULL
bericht longtext utf8_unicode_ci Ja NULL
kader varchar(255) utf8_unicode_ci Ja NULL
start_datum date Ja NULL
eind_datum date Ja NULL
bericht_tonen tinyint(1) Nee 0
June 2, 2009 at 3:06 am
Hi,
Ok, suppose you need to show the records having the date range of current date,
Then you try Tom Brown coding to get the result.
Select * from yourtable where getdate() between start_datum and eind_datum
ARUN SAS
June 2, 2009 at 3:49 am
Hi,
this is what i've tried:
Select * from `tbl_nieuws` where getdate() between `start_datum` and `eind_datum`
This provides the following error.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() between `start_datum` and `eind_datum`
LIMIT 0, 30' at line 1
Kind regards.
June 2, 2009 at 3:55 am
Hi,
Use the CURRENT_TIMESTAMP
instead of the getdate()
ARUN SAS
June 2, 2009 at 4:04 am
It works!!! Thanks a lot.
Kind regards,
Martin Smits
June 2, 2009 at 10:23 am
Please note that this is primarily a SQL Server site, so if you have a MySQL question, let us know that beforehand so that we don't give you the wrong answer.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply