Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-14-2022, 08:25 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Display SQL record from today and past 30 days?

I have this code, which lets me pull records from the 'created' column for todays date & time:

Quote:
SELECT * FROM table WHERE created >= CURRENT_TIMESTAMP;
What I'd like to do is have it pull records from the last 30 +/- days AND todays date, could anyone point me in the right direction as to how to make this happen?

Just to complicate it a little, Id like it to pull based on the month, so whether a recipe was added last year, 10 years ago, etc it'll still display the data as described below.

Basically, I'm wanting a pseudo page on my recipe site that gives visitors a list of 30 recipes for breakfast, lunch and dinner (that are recent additions) which will change every day, cycling through the last 90 recipe additions (per category)s, sort of like how the old POTD pages used to work.

TIA for any help.
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-14-2022, 09:14 PM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,058
select * from table
where created >=DATE_SUB(current_date(), INTERVAL 30 DAY)
order by created desc

That will stack all records created in the past 30 days in descending order so that the newest records are at the top of the pile.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-14-2022, 09:17 PM   #3
Tube Ace
So Fucking Banned
 
Industry Role:
Join Date: Nov 2008
Location: with your dream girl
Posts: 4,941
https://stackoverflow.com

You're welcome.
Tube Ace is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-14-2022, 10:11 PM   #4
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Quote:
Originally Posted by sarettah View Post
select * from table
where created >=DATE_SUB(current_date(), INTERVAL 30 DAY)
order by created desc

That will stack all records created in the past 30 days in descending order so that the newest records are at the top of the pile.

.
Much appreciated sir

I assume if I wanted to add a longer date I just change the '30'? Like, INTERVAL 30 DAY isnt a set parameter in php?
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-15-2022, 07:44 AM   #5
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Quote:
Originally Posted by Tube Ace View Post
GFY is faster
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-15-2022, 04:16 PM   #6
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Quote:
Originally Posted by Klen View Post
GFY is faster
With a lot less 'fluff' and arguing thrown in too
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
pull, recipe, date, display, additions, todays, days, records, created, list, page, recipes, data, pseudo, visitors, site, breakfast, basically, sort, categorys, potd, tia, pages, recent, dinner



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.