mysql return 'today' and 'yesterday' on ts

Posted on 2009-12-29
Last Modified: 2013-12-12

I'm looking for a way to let mysql return 'today' and 'yesterday' on a timestamp.

I manged to get today returned... But how can I also return yesterday?

  if(DATE(q.ts_submit) = CURDATE(),'today',q.ts_submit, 'q.ts_submit').") as ts_submit_date


Open in new window

Question by:Dennie
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    yesterday = today -1 day....


    LVL 24

    Accepted Solution

    select if(date(now())=date('20091228'), 'today', if(date(adddate(now(),-1))=date('20091228'), 'yesterday', 'another day'))

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now