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 6614153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:18:14+00:00 2026-05-25T20:18:14+00:00

I am writing a system that will show data from a selected month. The

  • 0

I am writing a system that will show data from a selected month. The user can select the month they want to look at, this then creates a URL something like this .com/page.php?month=03 the page as you can guess will take the idea and then use it to get data from the database from that month.

Now based on the month in the URL i am making to vars, $startdate $enddate start date based on this example is 2011-03-01, i then add 29 or 30 on to the days part of the date depending if the month has 31 or 30 days. Okay so i do the dates like this:

$startdate = mktime(0,0,0,date("$month"),date("01"),date("2011"));
if( $month==04 || $month==06 || $month==9 || $month==11)
{
    $enddate = mktime(0,0,0,date("$month"),date("01")+29,date("2011"));
}
else
{
    $enddate = mktime(0,0,0,date("$month"),date("01")+30,date("2011"));
}

Now when i try to get the data from the database with these variables it doesn’t seem to work, this is the query:

$getresults = mysql_query("SELECT * FROM table1 WHERE date BETWEEN $startdate AND $enddate ORDER BY date ASC");

The thing is if i change the vars to hard coded dates its works a treat… Anyone got any ideas? i was thinking it had something to do with the way the day is formatted? in my database its “Y-m-d” and is also the same in the php.

thank for any help people im really stuck on this one.

  • 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-25T20:18:14+00:00Added an answer on May 25, 2026 at 8:18 pm

    mktime produces dates as Unix timestamps (eg. ‘1317046059’) but your table stored dates in a different format (eg. ‘2011-09-26’). To make your queries work, you will need to convert your timestamps into the appropriate format:

    $enddate = date( 'Y-m-d', mktime(0,0,0,date("$month"),date("01")+29,date("2011")) );
    

    Update:

    Based on your new comment that your dates are stored as timestamps in your database, you will need to format your dates in this manner:

    $enddate = date( 'Y-m-d h:i:s', mktime(0,0,0,date("$month"),date("01")+29,date("2011")) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I'm writing a data provider that SSAS will use to get data from
I am currently writing a system that stores meta data for around 140,000 ish
I'm writing a C# POS (point of sale) system that takes input from a
I'm writing a silverlight application that resembles a shopping cart system. This app can
Currently I am writing a system for a user that on filling in a
I just creating a booking system and I want that the users will choose
I am writing a Maintenance Script for MongoDB that will compact collections from a
I'm writing a small system that will allow me to sell my band's music
I am writing an application that will copy files from its assets directory to
I am writing an interface into our system that will allow end to end

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.