#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    15
    Rep Power
    0

    Returning a list of dates that fall only on a Saturday from MySQL.


    I would like to query MySQL for a list of dates lets sat starting on Jan 1 of the current year for each date that falls on Saturday for the next 365 days. Is there a way to query MySQL like that?

    Thanks for any help...
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,170
    Rep Power
    4274
    why mysql? you don't need a database for that type of task, a simple routine in any programming language will do it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    15
    Rep Power
    0
    I suppose I could write a script in PHP that accomplishes this task. I was just wondering if something like that is possible with MySQL. I don't readily see a way to do that in MySQL yet but I am looking into the documentation.
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,170
    Rep Power
    4274
    Originally Posted by sepoto
    I don't readily see a way to do that in MySQL yet
    and i'm not going to tell you how

    unless, of course, you give a full explanation of what you plan to do with this list of saturdays...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    15
    Rep Power
    0
    Alright... I am working on a time keeping program where is time sheet would be represented by the fields id,weekending where weekending would hold the last day of the week which is always a Saturday. There should be no duplicate time sheets in the table. Only one time sheet per Saturday should be in the table. That is how I must design it.
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,170
    Rep Power
    4274
    Originally Posted by sepoto
    Only one time sheet per Saturday should be in the table. That is how I must design it.
    use a UNIQUE constraint to guarantee uniqueness

    then, when you go to INSERT rows into this table, generate the saturday date yourself in the application program
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo