Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6387949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:13:05+00:00 2026-05-25T03:13:05+00:00

Background : I have a database table filled with over 500 rows . The

  • 0

Background:
I have a database table filled with over 500 rows. The data is from a websites json API. There is a column called created_at which mimics the json API not the local row created_at time. Here is an example of the date / time format from the API 2009-12-10T20:08:00+0000. The column in the database has the type varchar which may be problematic later on.

Problem:
I to wish setup a specific query or if a query cannot be achieved run all of the database rows through a loop. I want the ability to query posts at set date intervals, for instance, todays date is Aug 28th 2011, I want the weekly, monthly, and yearly posts that match that date.

Weekly would look like this (ie. Aug 28th 2011, Aug 21th 2011, Aug 14th 2011, Aug 07th 2011 ).

Monthly would look like this (ie. Aug 28th 2011, Jul 28th 2011,Jun 28th 2011, May 28th 2011 ).

Yearly would look like this (ie. Aug 28th 2011, Aug 28th 2010, Aug 28th 2009 ).

Special cases
If one of these is not present I would like the ability to retrieve whichever preceding or proceeding row date is closer to the date requested. If their are multiple rows for one date I just want the first one.

Any help would be greatly appreciated.

UPDATE
I have added a column with the type datetime and have pulled and updated the rows with the new created_at_datetime column which correspondes to date('Y-m-d H:i:s', $jsonDate). I still have little idea how to form the mysql query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:13:05+00:00Added an answer on May 25, 2026 at 3:13 am

    If you have to convert the date, use strftime(), http://php.net/manual/en/function.strftime.php

    Use srttotime() to calculate dates in the past/future; get the previous month and last day of the month, then add a 24:59:59 signaling the last possible second of the month, and a 00:00:00 for the 1st possible second.

    To get only 1 result in the database call, use LIMIT 1, and order by asc/desc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dynamically-created table that is filled with data from a
Background: I have a database table which is for received_msgs The table has two
Background We have worker processes that read jobs from a table in SqlServer then
Background: In my database table, I have two timestamps timeStamp1 = 2011-08-23 14:57:26.662 timeStamp2
Background: I have a PostgreSQL (v8.3) database that is heavily optimized for OLTP. I
I have a background worker running a long database task. i want to show
I have a strong database background but very little practical experience with ms sql
Background: we have an application that generates reports from HTML (that may or may
Here's some background info. I have three MySQL tables (all InnoDB). The first table
Background: I have one Access database (.mdb) file, with half a dozen tables in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.