Array of Dates from MYSQL?...

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Array of Dates from MYSQL?...

    This has been puzzelling me for a couple of weeks now, and just can't figure
    it out.

    Does anyone know how to return an array of dates from MySQL given the start
    date and end date. The database has a rows containing 'start date' and 'end
    date' I need an array containing all the days between 'start date' and 'end
    date', ie:

    Start Date = 15/06/2004
    End Date = 17/06/2004

    Array returned: 15/06/2004,16/06/2004,17/06/2004

    Hope this make sense?... I would love to hear if anyone has done this before
    or has any idea's how I can do this.

    MySQL 4.0 and PHP 4

    Thanks in advance.


    rob Guest

  2. Similar Questions and Discussions

    1. How to you compare dates in a query in Mysql
      Dear friends, Plesae help in finding the correct syntax for comparing two dates in a query in MySql database Thank you Subodh Gupta
    2. MySQL Dates
      Hello, I have CFM pages with Searching on Dates in MySQL. As you know MySQL Dates are "yyyy-mm-dd" format. However, we want date entering formats...
    3. Searching on Dates in MySQL
      Hello, I have CFM pages with Searching on Dates in MySQL. As you know MySQL Dates are "yyyy-mm-dd" format. However, we want date entering formats...
    4. Convert CF list of dates to javascript array
      I have a list of dates <cfset myDatesList= "2005-05-29 19:50:16.0,2005-05-30 19:51:30.0,2005-05-31 19:52:24.0,2005-06-01 19:55:55.0,2005-06-02...
    5. Web form dates to MySQL
      I am building a admin form (PHP/MySQL), so staff can input Job Vacancy descriptions into the Website via a Web form that can be displayed on the...
  3. #2

    Default Re: Array of Dates from MYSQL?...

    I've done this before, and what I had to do is store the dates (both
    start, and end) as UNIX time (number of seconds/miliseconds from Jan
    1, 1970), and then convert my dates to UNIX time also. Then, you can
    do a greater than (>) and less than (<) comparison on your respective
    fields, like so:

    SELECT * FROM my_table
    WHERE
    start_date >= '$start_date'
    AND
    end_date <= '$end_date';

    And formatting the UNIX time is very simple, you can use either date()
    or strftime() to get a more appealing time string.

    This of course is just my personal opinion, and of course there are
    other ways of doing this. I just find UNIX time to be a bit more
    flexible because I can rearrange the date format, to my fickle heart's
    content.

    On Mon, 28 Jun 2004 16:20:37 +0000 (UTC), "rob" <rob@one01.co.uk>
    wrote:
    >This has been puzzelling me for a couple of weeks now, and just can't figure
    >it out.
    >
    >Does anyone know how to return an array of dates from MySQL given the start
    >date and end date. The database has a rows containing 'start date' and 'end
    >date' I need an array containing all the days between 'start date' and 'end
    >date', ie:
    >
    >Start Date = 15/06/2004
    >End Date = 17/06/2004
    >
    >Array returned: 15/06/2004,16/06/2004,17/06/2004
    >
    >Hope this make sense?... I would love to hear if anyone has done this before
    >or has any idea's how I can do this.
    >
    >MySQL 4.0 and PHP 4
    >
    >Thanks in advance.
    >
    eclipsboi Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139