Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
comparing 2 timestamp
Old 06-05-2007, 02:12 PM comparing 2 timestamp
Average Talker

Posts: 22
Trades: 0
Hi,

i would like to compare two value of timestamp

so my code is
Code:
$todayDate= date("Y-m-d 00:00:00");
$todayEnd= date("Y-m-d 23:59:59");

$query_reg_list= "select p.patientId, m.MRId, p.pname, p.alergi";
$query_reg_list.=" from MR m, patient p, havePatient h where h.MRId=m.MRId and h.patientId=p.patientId and regDate>='$todayStart' and regDate<='$todayEnd' order by p.patientId";
does anyone know how to compare these values? cause i always get empty result for that..
thank's for our attention
moccacinoe is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-05-2007, 02:54 PM Re: comparing 2 timestamp
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
The date function I think is messing you up. Here is an attempt modified with the sql between function.

PHP Code:
$query_reg_list 'SELECT p.patientId, m.MRId, p.pname, p.alergi '
                
'FROM MR m, patient p, havePatient h '
                
'WHERE h.MRId = m.MRId AND '
                
'h.patientId = p.patientId AND '
                
'regDate BETWEEN "' date('Y-m-d') . ' 00:00:00" AND "' date('Y-m-d') . ' 23:59:59" '
                
'ORDER BY p.patientId'
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-05-2007, 11:12 PM Re: comparing 2 timestamp
Average Talker

Posts: 22
Trades: 0
hi..
thank's for your reply..
i've tried your code, but it still give me empty result with 2 warnings in mysql =)

Code:
warning 1292: incorrect datetime value: '' .date('Y-m-d') . ' 00:00:00' for column 'regDate' at row 1
warning 1292: incorrect datetime value: '' .date('Y-m-d') . ' 23:59:59' for column 'regDate' at row 1
i've tried to change the date() function to curdate() but it still gives me empty result and same warnings..
can you please help me with this problem? thanks a lot..

regards,
moccacinoe is offline
Reply With Quote
View Public Profile
 
Old 06-05-2007, 11:26 PM Re: comparing 2 timestamp
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Your error is stating that you are passing literal php code to your sql - Is PHP turned on?

You can use sql to do this completely

Code:
SELECT p.patientId, m.MRId, p.pname, p.alergi 
FROM MR m, patient p, havePatient h 
WHERE h.MRId = m.MRId AND 
h.patientId = p.patientId AND 
regDate BETWEEN DATE_FORMAT(NOW(), "%Y-%m-%d 00:00:00") AND DATE_FORMAT(NOW(), "%Y-%m-%d 23:59:59") 
ORDER BY p.patientId
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-06-2007, 12:49 AM Re: comparing 2 timestamp
Average Talker

Posts: 22
Trades: 0
Hi..
thank's for the repliess..
that's work... =)
thank's a lot
moccacinoe is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to comparing 2 timestamp
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20760 seconds with 12 queries