What's wrong with this?
8 Message(s) by 3 Author(s) originally posted in php sql
| From: Mad Hatter |
Date: Thursday, October 11, 2007
|
I need to find out whos birthdays land today. The DOB is
store d in a
standard
Unix timestamp. I'm trying to use the following but it throws up a
syntax error.
SELECT numberx FROM member WHERE
date ('d m',dob)=date('d m',time())
Where am I going wrong?
| From: Virginner |
Date: Thursday, October 11, 2007
|
wrote in
message
I need to find out whos birthdays land today. The DOB is stored in a
standard Unix timestamp. I'm trying to use the following but it throws up
a
syntax error.
SELECT numberx FROM member WHERE date('d m',dob)=date('d m',time())
Where am I going wrong?
DATE() doesn't take any parameters - you're getting confused with PHP's
date, or
SQL 's DATE_FORMAT
TIME() only returns the time of day
Are you sure you've the dob as a Unix Timestamp? That'd be weird.
Now for example'd be "1192147732" in Unix Time.
It's more likely you've the dob as a DATE column-type, e.g. 1943-12-31
It that's the case, then use:
SELECT numberx FROM member WHERE DAYOFYEAR(dob)=DAYOFYEAR(NOW())
Have fun.
| From: Captain Paralytic |
Date: Friday, October 12, 2007
|
wrote in message:
I need to find out whos birthdays land today. The DOB is stored in a
standard Unix timestamp. I'm trying to use the following but it throws up a
syntax error.
SELECT numberx FROM member WHERE date('d m',dob)=date('d m',time())
Where am I going wrong?
In future, might I suggest that you post the
text of the error!
| From: Mad Hatter |
Date: Friday, October 12, 2007
|
Hi
DATE() doesn't take any parameters - you're getting confused with PHP's
date, or SQL's DATE_FORMAT
TIME() only returns the time of day
That's where I'm going wrong then. I'm using php commands on a sql query
:-(
Are you sure you've the dob as a Unix Timestamp? That'd be weird.
Now for example'd be "1192147732" in Unix Time.
Yup, definetely Unix timestamp. I prefer storing dates that way.
It's more likely you've the dob as a DATE column-type, e.g. 1943-12-31
It that's the case, then use:
Thanks but due to unix date no help :-(
| From: Captain Paralytic |
Date: Friday, October 12, 2007
|
wrote in message:
Hi
> DATE() doesn't take any parameters - you're getting confused with PHP's
> date, or SQL's DATE_FORMAT
> TIME() only returns the time of day
That's where I'm going wrong then. I'm using php commands on a sql query
:-(
> Are you sure you've the dob as a Unix Timestamp? That'd be weird.
> Now for example'd be "1192147732" in Unix Time.
Yup, definetely Unix timestamp. I prefer storing dates that way.
> It's more likely you've the dob as a DATE column-type, e.g. 1943-12-31
> It that's the case, then use:
Thanks but due to unix date no help :-(
Well, let's look at this.
Most of us when using a
tool like a
database system choose the most
appropriate facilities, to ensure efficiency and ease of maintenance.
You think you know better and choose to store times as unix times.
Next, you've proved that you couldn't be bothered to check your
problem in the manual. If I get a syntax error, I go to the manual to
see what I have done wrong. There you would've seen that you were
using totally the wrong syntax and would've seen the correct one.
When I want to do something and I'm not sure how to, I try searching
Google or the manual.
Putting the words
mysql unix timestamp
into Google brings up the correct page of the mysql user manual as the
first
hit . Going to that page (by the way, that'sthe page you'd
already have been on had you bothered to llok up he syntax error) and
searching for UNIX, you would've hit straight upon the FROM_UNIXTIME
function.
So, not only do you "prefer" not to store times properly, you also
"prefer" not to bother looking at the manual or doing any other
obvious searches to help yourself. You "prefer" to get other people to
sort out your messes for you.
| From: Virginner |
Date: Friday, October 12, 2007
|
wrote in message
Hi
DATE() doesn't take any parameters - you're getting confused with PHP's
date, or SQL's DATE_FORMAT
TIME() only returns the time of day
That's where I'm going wrong then. I'm using php commands on a sql query
:-(
Are you sure you've the dob as a Unix Timestamp? That'd be weird.
Now for example'd be "1192147732" in Unix Time.
Yup, definetely Unix timestamp. I prefer storing dates that way.
It's more likely you've the dob as a DATE column-type, e.g. 1943-12-31
It that's the case, then use:
Thanks but due to unix date no help :-(
(Still do not know why you'd store a dob as Unix Timestamp, but anyway)
.... simply convert your UNIX_TIMPSTMP to a normal date/time, using
FROM_UNIXTIME()
So, for example, to get today's day of the yea if it was a Unix Timestamp:
SELECT DAYOFYEAR(FROM_UNIXTIME(UNIX_TIMESTAMP()))
So, to solve your problem:
SELECT numberx FROM member
WHERE DAYOFYEAR(FROM_UNIXTIME(dob))=DAYOFYEAR(NOW())
| From: Mad Hatter |
Date: Friday, October 12, 2007
|
wrote in message:
Well, let's look at this.
Most of us when using a tool like a database system choose the most
appropriate facilities, to ensure efficiency and ease of maintenance.
You think you know better and choose to store times as unix times.
I have my own reasons for storing as a Unix timestamp. I'm sure that at
some time in the past you may have done something that others (or even the
manual!) says isn't the right way of doing things because it's far more
convenient.
Next, you've proved that you couldn't be bothered to check your
problem in the manual. If I get a syntax error, I go to the manual to
see what I have done wrong. There you would've seen that you were
using totally the wrong syntax and would've seen the correct one.
I did look at the manual but as it was late at night and I was tired I made
the mistake of looking at the php manual and not the mysql manual. But
there again I'm sure a Mr.Perfect like yourself is incapable of making such
mistakes.
I can not be bothered with the rest of your message. Your just not worth the
effort. Perhaps one day you might need help (but I doubt it seeing as you
know everything) and someone gives you such a helpful
reply as the one you
gave me.
I'm just glad there are people like Virginner about who are wiling to help.
| From: Mad Hatter |
Date: Friday, October 12, 2007
|
wrote in message:
Thanks for the reply. I have got everything worked out now :-)
Next Message: Slow results
Blogs related to What's wrong with this?
What's wrong with this picture?
QUOTE(Michael_Aivaliotis @ Oct 8 2007, 12:03 AM) <{POST_SNAPBACK}>. Here's the VI, bonus to whoever figures it out... and yes, it works as expected. The caller will be broken if this output is not wired.
...
What's wrong with this picture?
How about detachable event structure nodes? [attachment=7213:1.png] [attachment=7214:detachableventnode.vi] (V8.5)
Please help me!? I don't know whats wrong.
I seem to have downloaded something by accident which is causing me loads of problems. For starters I keep getting security pop-ups, not from windows, but from some anti-spyware company, telling me i have bad malware/spyware/adware and
...
What's wrong with this picture?
QUOTE(Michael_Aivaliotis @ Oct 10 2007, 11:36 AM) <{POST_SNAPBACK}>. How about detachable event structure nodes? I remember that one: DetachableStructurePartsEnabled=TRUE. Does that mean the other thing can only be enabled with an INI
...
How to add some pages in Information slide-box
information box text in sideboxes/information.
php define('BOX_INFORMATION_CONDITIONS', 'Conditions of Use'); define('BOX_INFORMATION_TEST1', 'Test page 1');
... :frusty::frusty::frusty:
What's wrong with me :no:
[C]What's wrong here?
EDIT: OMG IM SO STUPID lol. i found the error. thanks anyway! (I bolded the mistakes i had on the code) Please note that i'm only a beginner in C. So take it easy on me please.:blushing: #include
int main() ...