| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

07-15-08, 22:14
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
|
current weekdays
|
|
hi,
how can I return the current weekdays. mon - current.
thanks

__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 02:18
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
SELECT DAYNAME(CURRENT_DATE)
this returns Sunday, Monday, etc.
if you want just 3 characters, use LEFT(DAYNAME(CURRENT_DATE),3) or, alternatively, DATE_FORMAT(CURRENT_DATE,'%a')
|
|

07-16-08, 02:27
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
|
|
thanks
but it only returns the current day name,
Code:
SELECT
DAYNAME(current_date) as 'current week'
FROM coding_log
it suppose to return the current 7 days.
Code:
SELECT
`date`
FROM coding_log
where week(`date`) = week(current_date)
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 03:31
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
what is this coding_log table? how many rows in there? can i see samples?
|
|

07-16-08, 03:48
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
coding_table has many rows, but i only need the `date`, and convert it to weeks. i need week to date of the current day.
sample is just days that is with in this current week.
thanks
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 03:58
|
|
Registered User
|
|
Join Date: Aug 2004
Location: France
Posts: 754
|
|
PHP Code:
SELECT DATE_FORMAT(CURRENT_DATE, '%v');
%v gives the week number between 01 and 53, each week beginning on monday.
For the different formats, see the DATE_FORMAT doc here.
HTH
rbaraer
__________________
ORA-000TK : No bind variable detected... Shared Pool Alert code 5 - Nuclear query ready  .
|
|

07-16-08, 04:17
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
thanks,
my field is
`date`
and i want the current week of my field date from mon to fri.
week(current_date)
thanks
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 05:31
|
|
Registered User
|
|
Join Date: Aug 2004
Location: France
Posts: 754
|
|
Quote:
|
Originally Posted by homer.favenir
thanks,
my field is
`date`
and i want the current week of my field date from mon to fri.
week(current_date)
thanks
|
And can't you try ???
Code:
SELECT `date`
FROM coding_log
where date_format(`date`, '%v') = date_format(current_date, '%v');
will return rows for which the date field is in the current week.
Isn't it what you want ?
__________________
ORA-000TK : No bind variable detected... Shared Pool Alert code 5 - Nuclear query ready  .
|
|

07-16-08, 06:21
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
yes it is, thanks
isnt this the same?
where week(`date`) = week(current_date);
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 08:45
|
|
Registered User
|
|
Join Date: Aug 2004
Location: France
Posts: 754
|
|
Quote:
|
Originally Posted by homer.favenir
yes it is, thanks
isnt this the same?
where week(`date`) = week(current_date);
|
Yes, week() also works. Choose the second parameter wisely though.
I didn't know of it and it was not clear for me that you had solved your problem  .
Regards,
rbaraer
__________________
ORA-000TK : No bind variable detected... Shared Pool Alert code 5 - Nuclear query ready  .
|
|

07-16-08, 08:48
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
Quote:
|
Originally Posted by homer.favenir
i need week to date of the current day.
|
what does "week to date" mean?
so you're not interested in the name of the day of the week?
when you ask a question, you really should give more information, with lots of sample data and an indication of what you want to return from that sample data
|
|

07-16-08, 08:52
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
Quote:
|
Originally Posted by homer.favenir
i want the current week of my field date from mon to fri.
|
well, today is wednesday (at least, it is over here)
so you want thursday and friday of this week too? and why not sunday and saturday?
and do you actually want data from your coding_log table at all, or are you just interested in the dates themselves?
so you see what i mean about asking unclear questions?
|
|

07-16-08, 23:16
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
saturday and sunday is ok. as long it is the current week.
week to date is the current week of the month or year.
i like to have a list of current week from my field `date`.
the query should return the current week from the field `date`
i will use the query in my php program, thats why i just need the`date` field only that returns current week.
thanks

__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|

07-16-08, 23:22
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
the current week is a single number
so "a list of the current week" doesn't make sense to me
also, "the query should return the current week from the field `date`" doesn't make sense, assuming that there is more than one row with different values of `date`
could you perhaps try something different? how about showing a few sample rows of your table, and then tell us what you want the query to return from those rows
|
|

07-17-08, 00:41
|
|
Registered User
|
|
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
|
|
these are the values of my field `date`
Code:
dtestarted
2008-04-08 19:48:47
2008-04-08 20:22:24
2008-04-08 20:10:38
2008-04-17 08:44:40
2008-04-17 08:19:40
2008-04-17 08:51:40
2008-04-17 09:11:17
2008-04-17 12:41:40
2008-04-18 10:16:31
2008-04-18 09:50:51
2008-04-18 09:35:35
2008-04-18 15:26:01
2008-04-18 15:21:58
2008-04-18 15:15:56
2008-04-19 11:40:47
2008-04-19 16:16:25
2008-04-19 16:02:35
2008-04-19 17:15:44
2008-04-19 18:34:40
2008-04-19 18:37:14
2008-04-19 18:57:50
2008-04-19 17:30:23
2008-04-19 16:31:03
2008-04-21 08:26:46
2008-04-19 20:00:00
2008-04-19 19:51:17
2008-04-19 19:41:23
2008-04-19 19:05:28
2008-04-24 07:13:40
2008-04-24 07:26:13
2008-04-23 10:18:28
2008-04-28 19:22:06
2008-04-29 01:52:17
2008-05-01 01:06:03
2008-05-01 00:43:11
2008-05-01 00:22:33
2008-05-03 00:13:46
2008-05-02 22:50:48
2008-05-02 22:28:59
2008-05-03 03:36:29
2008-05-03 03:12:17
2008-05-03 04:44:28
2008-05-03 04:32:36
2008-05-04 03:13:46
2008-05-04 02:24:23
2008-05-04 05:08:07
2008-05-03 02:49:05
2008-05-03 02:36:09
2008-05-06 04:15:07
2008-05-06 04:12:55
2008-05-06 19:18:14
2008-05-05 19:40:53
2008-05-07 00:33:24
2008-05-08 22:31:28
2008-05-08 21:46:14
2008-05-06 19:47:39
2008-05-09 22:23:25
2008-05-07 01:48:56
2008-05-07 03:56:28
2008-05-07 03:48:11
2008-05-08 02:13:21
2008-05-08 00:50:07
2008-05-08 00:24:27
2008-05-09 19:31:37
2008-05-09 00:47:51
2008-05-13 07:47:03
2008-05-15 07:30:57
2008-05-14 12:39:45
2008-05-16 10:41:55
2008-05-16 10:33:48
2008-05-16 10:19:47
2008-05-16 09:32:12
2008-05-17 13:16:48
2008-05-15 08:50:54
2008-05-15 12:33:41
2008-05-20 08:43:58
2008-05-20 08:31:33
2008-05-20 09:18:32
2008-05-21 07:30:51
2008-05-21 08:34:54
2008-05-21 10:31:43
2008-05-22 12:22:32
2008-05-22 10:26:13
2008-05-24 10:43:03
2008-05-29 20:27:00
2008-05-30 00:05:32
2008-05-31 02:24:17
2008-06-04 19:42:54
2008-06-04 22:47:38
2008-06-06 20:05:36
2008-06-05 22:26:37
2008-06-05 22:06:35
2008-06-10 15:07:33
2008-06-12 14:27:07
2008-06-12 12:30:21
2008-06-13 10:24:30
2008-06-14 13:16:49
2008-06-17 08:33:36
2008-06-17 07:12:01
2008-07-15 13:17:38
2008-07-16 12:18:13
2008-07-16 10:24:03
sorry, what i mean is list of days of the current week.
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|