where question regarding dates : [SOLVED]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

where question regarding dates : [SOLVED]

Post by waskelton4 »

This should be simple.. hope someone can help

in my sql..

Code: Select all

SELECT Date_Format(tsTimeStamp, '%m-%d-%Y: %r') as dtCreated
FROM table WHERE dtCreated LIKE '2004-01-01%' ORDER BY dtCreated
is the where applied to tsTimeStamp or the post-formated dtCreated?


TIA!
Will
Last edited by waskelton4 on Mon Jan 12, 2004 1:05 pm, edited 1 time in total.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

[wrong]
It is applied to the post-formated dtCreated
[/wrong]

[edit]
This query will rise an error of this type:

Code: Select all

Unknown column 'dtCreated' in 'where clause'
[/edit]
Last edited by scorphus on Mon Jan 12, 2004 1:35 pm, edited 1 time in total.
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

Post by waskelton4 »

Thank you much!
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

OMG! :oops: I'm sorry, forum mate. I'm completely wrong! I read your post a bit fast and understood that you were asking about the ORDER BY clause.

When you try this query you will get an error from MySQL saying that there is no dtCreated filed on the table.

Please excuse my lack of attention.

Regards,
Scorphus.
waskelton4
Forum Contributor
Posts: 132
Joined: Mon Sep 09, 2002 6:42 pm

Post by waskelton4 »

A HA! that's why i've been getting those wierd results..

Both of my tables do have a dtCreated field.. so i get no error.. but i get bogus data..

Thanks for the re-reply :)

Now i know what i must do..

peace
will
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Well, it's nice you fixed things and know what to do. Sorry for making you spend your time :oops:

Regards,
Scorphus.
Post Reply