dbTalk Databases Forums  

days of a week

comp.databases.mysql comp.databases.mysql


Discuss days of a week in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
fabrice régnier
 
Posts: n/a

Default days of a week - 12-16-2010 , 12:05 PM






hi all,

I have 2 variables, varYEAR and varWEEK (ie: 2010 and 50)

I'd like to know the days of this week (it starts on mondays). Or at
least the first day of this week.

2010-12-13
2010-12-14
2010-12-15
2010-12-16
2010-12-17
2010-12-18
2010-12-19

It seems the mysql date and time functions only take date variables and
no week number variable.

any hint ?

regards,

f.

Reply With Quote
  #2  
Old   
strawberry
 
Posts: n/a

Default Re: days of a week - 12-16-2010 , 12:22 PM






SELECT STR_TO_DATE('201050 Monday', '%X%V %W');
+-----------------------------------------+
Quote:
STR_TO_DATE('201050 Monday', '%X%V %W') |
+-----------------------------------------+
2010-12-13 |
+-----------------------------------------+

Reply With Quote
  #3  
Old   
fabrice régnier
 
Posts: n/a

Default Re: days of a week - 12-16-2010 , 12:30 PM



Le 16/12/2010 19:22, strawberry a écrit :
Quote:
SELECT STR_TO_DATE('201050 Monday', '%X%V %W');
+-----------------------------------------+
| STR_TO_DATE('201050 Monday', '%X%V %W') |
+-----------------------------------------+
| 2010-12-13 |
+-----------------------------------------+
yes, i missed this one.

thanx a lot

regards,

f.

Reply With Quote
  #4  
Old   
Luuk
 
Posts: n/a

Default Re: days of a week - 12-16-2010 , 12:35 PM



On 16-12-10 19:05, fabrice régnier wrote:
Quote:
hi all,

I have 2 variables, varYEAR and varWEEK (ie: 2010 and 50)

I'd like to know the days of this week (it starts on mondays). Or at
least the first day of this week.

2010-12-13
2010-12-14
2010-12-15
2010-12-16
2010-12-17
2010-12-18
2010-12-19

It seems the mysql date and time functions only take date variables and
no week number variable.

any hint ?

regards,

f.
set @A:=(week(now())-week('2010-01-01')-1)*7;
select ADDDATE('2001-01-01', x+@a) from number where x between 3 and 9;

Where the 'number'table contains integers, at least from 3 until 9


--
Luuk

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.