Hi David Powers,
Thanks for your input regarding the week number problem.
re.
> The way to do it is to use
DATE_FORMAT(datBegin,'%u') as part of your query. For
example:
SELECT thisCol, thatCol, DATE_FORMAT(datBegin,'%u') as
week_num
FROM mytable
ORDER BY week_num DESC
This is exactly what I have tried over and over again, many
times. This
approach fails when you add the WHERE statement:
WHERE kalendar.week_nbr = servicegrupp.vecka
However, when I hard code the week_nbr into the kalendar
table, then the
WHERE statement works as intended. There is a match, in other
words.
It appears that the reason it does not work unless the
week_nbr is in the
table, is that "week_num" (as you have it) from the query is
not a field but
something else, perhaps a variable. I'm not sure about the
terminology. To
match output from the table with output from an AS statement
in the query
does not work -- at least not in my experience.
I guess the scenario is one of relations. In other words the
"week_nbr"
from the kalendar table relates to the "vecka" in the
servicegrupp table.
When both are present in their respective tables, the match
occurs.
To try to match them at the output stage, using the AS
statement in the
query, does not work. The wrong "week_nbr" is inserted --
always the number
from the top record in the table, it appears.
I know that in the case of relational tables, it is possible
to output the
id from one table to the foreign key in the related table. It
is this
facility I need to find, somehow, even though I am not
dealing with the ids.
These are my reasonings at the moment. But there is probably
a better, more
elegant way to accomplish the needed match.
Thanks again for your willingness to help.
Curt L. Gustafsson
----- Original Message -----
From: forums@adobe.com
To: gustafsson@ibtnet.org
Sent: Thursday, May 31, 2007 7:31 PM
Subject: Dreamweaver Support subscription update.
Newsgroup User has posted a message entitled Re: Dreamweaver
MX extracting
week number.
Message Posted on: Thursday May 31,2007 10:31:12 AM
curtgus wrote:
> In the process of submitting that date, I want a portion
of it (the
> "week-number" represented by the date that the user
entered) to be
submitted to
> another field (week_nbr) in the same MySQL database and
table.
You don't need to. The information stored in datBegin already
contains
that information, as you point out yourself.
> The formating of the week number is not a problem. It is
done with
> DATE_FORMAT(datBegin,'%u').
You're approaching the problem the wrong way. You presumably
want to
store the week number so that you can search according to
week number or
display results by week number. The way to do it is to use
DATE_FORMAT(datBegin,'%u') as part of your query. For
example:
SELECT thisCol, thatCol, DATE_FORMAT(datBegin,'%u') as
week_num
FROM mytable
ORDER BY week_num DESC
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
You can view the message at
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=189&threadid=1272474&forumid=12.