How to pick next or prevoius day?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vasavivenu
    New Member
    • Feb 2011
    • 37

    How to pick next or prevoius day?

    Hi,
    How can i pick next or prevoius day in mysql? Any function like next_day in Oracle ?
    --Thanks
    vasavivenu
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Try
    Code:
    SELECT DATE_ADD(NOW(), INTERVAL 1 DAY);
    You can use the DAY() function with that to extract the day of the month.

    Comment

    • vasavivenu
      New Member
      • Feb 2011
      • 37

      #3
      Thanq sir, but i need "next_day(' 01-mar-2011','tue') in oracle" these functionality. means this query returns me 08-mar-2011 as the answer. So i need the replacement this function in mysql.

      Thanks

      vasavivenu

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You use the same function but you have to use a variable number for the amount of days you want to add. To do so, you could use an IF to return 1 if it's a Monday and 8 - Weekday() otherwise.

        Or you can get tricky and use 8 - (Weekday + (7 - Weekday) \ 7 * 7. Where "\" is integer division.

        Comment

        Working...