?
Solved

mysql return 'today' and 'yesterday' on ts

Posted on 2009-12-29
2
Medium Priority
?
613 Views
Last Modified: 2013-12-12
Hi,

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?
SELECT
  if(DATE(q.ts_submit) = CURDATE(),'today',q.ts_submit, 'q.ts_submit').") as ts_submit_date
FROM...

Open in new window

0
Comment
Question by:Dennie
2 Comments
 
LVL 143

Expert Comment

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

RTFM: dev.mysql.com/doc/mysql/en/date-and-time-functions.html

DATE_SUB(CURDATE , INTERVAL 1 DAY)
0
 
LVL 24

Accepted Solution

by:
mankowitz earned 2000 total points
ID: 26138385
select if(date(now())=date('20091228'), 'today', if(date(adddate(now(),-1))=date('20091228'), 'yesterday', 'another day'))
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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