LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-21-2010, 03:13 AM   #1
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 167

Rep: Reputation: 15
Match datetime by the minute (not an exact match by the second) [mysql]


I have the following query:

Code:
$sql="SELECT table1.datetime, table1.user_id, table2.ip, FROM table1,table2 WHERE id='$id' AND (table1.id = table2.id AND table1.datetime = table2.datetime)";
In table2 the datetime fields are about 1 to 2 seconds off due to the source of the data, which I cannot change.

Is it possible via a query match table1.datetime & table2.datetime by HH:MM (ie. to the minute instead of to the second)?

Thanks & regards
 
Old 10-21-2010, 05:43 PM   #2
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by hattori.hanzo View Post
I have the following query:

Code:
$sql="SELECT table1.datetime, table1.user_id, table2.ip, FROM table1,table2 WHERE id='$id' AND (table1.id = table2.id AND table1.datetime = table2.datetime)";
In table2 the datetime fields are about 1 to 2 seconds off due to the source of the data, which I cannot change.

Is it possible via a query match table1.datetime & table2.datetime by HH:MM (ie. to the minute instead of to the second)?
I used:

Code:
DATE_FORMAT( table1.datetime, '%Y-%m-%d %H:%i' ) =  DATE_FORMAT( table2.datetime, '%Y-%m-%d %H:%i' ))
which solved it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
grep question - match exact string Panagiotis_IOA Linux - General 2 01-20-2014 04:34 AM
egrep for only words(exact match) msgforsunil Linux - Newbie 4 04-14-2010 05:27 AM
Awk: match string in exact position sebelk Programming 2 10-19-2009 02:15 PM
how to match the exact pattern using grep utility vinaytp Linux - Newbie 3 05-11-2009 12:36 AM
how to find an exact substring match? ldp Programming 7 02-22-2005 06:28 AM


All times are GMT -5. The time now is 01:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration