MYSQL - sql query date time
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
i have a datestamp field in my table structure. using sql, i want to find any user who registered in yesterdays date using these time range.
eg: 2010-02-06 14:00:00 2010-02-07 10:00:00
i will be running this query once a day to grab users.
so tomorrow will be: 2010-02-07 14:00:00 2010-02-08 10:00:00
the day after tomorrow will be: 2010-02-08 14:00:00 2010-02-09 10:00:00
etc, etc.
select distinct * from users where loggedTime...
not sure how to query the date range? any ideas thanks
This question and answers originated from www.stackoverflow.com
Question by Menew (2/8/2010 12:35:44 AM)
Answer |
SQL Server
where loggedTime between
DATEADD(hour, 14, DATEADD(DAY, 0, DATEDIFF(DAY,0,getdate()))) and
DATEADD(hour, 34, DATEADD(DAY, 0, DATEDIFF(DAY,0,getdate())))
MySQL
where loggedTime between
curdate() + interval 14 hour and
curdate() + interval 34 hour
Answer by Adam Ruth
Find More Answers