distal-attribute
distal-attribute
distal-attribute
distal-attribute

Best forum for MySQL expertise

User, date Message
Written by kezMoney, Euro
4 years ago
Category: General
21 posts since Tue, 21 Sep 10

I have a table called pay.

It has a column called date with many yyyy-mm-dd records.
I wish to test pay.date with the following MS Excel VBA function and then insert the result of the function in another column called week.

I would be very grateful for an implementation in MySQL so i can run it in HeidiSQL.

Which is the best forum for MySQL ?

Function Week_w(av)
Dim dd, fy, m, y, d
m = Month(av)
y = Year(av)
d = Day(av)
fy = y
If m * 100 + d < 406 Then fy = fy - 1
dd = DateSerial(y, m, d) - DateSerial(fy, 4, 6)
week_w = Int(dd \ 7 + 1)
End Function


Kez
Written by ansgar
4 years ago
4800 posts since Fri, 07 Apr 06
I guess your week column shall contain the week number (1-53)? In that case it's so easy you should not store that redundant data into a new column, just select date with a format function when you need the week:

SELECT DATE_FORMAT(`date`, '%u') FROM pay

mysql-docs wrote:
%U Week (00..53), where Sunday is the first day of the week
%u Week (00..53), where Monday is the first day of the week
%V Week (01..53), where Sunday is the first day of the week; used with %X
%v Week (01..53), where Monday is the first day of the week; used with %x

Written by kezMoney, Euro
4 years ago
21 posts since Tue, 21 Sep 10
Thanks Anse,
I have not got to grips with computation in mySQL yet and cannot find a web page to show me so i need a rather full solution having grappled with that one over anumber of hours.
Is there a forum somewhere ?
Many Thanks for all your help, it is kindly appreciated
Written by ansgar
4 years ago
4800 posts since Fri, 07 Apr 06
http://forums.mysql.com/
 

Please login to leave a reply, or register at first.