Best forum for MySQL expertise

kez's profile image kez posted 14 years ago in General Permalink

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
ansgar's profile image ansgar posted 14 years ago Permalink
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


%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

kez's profile image kez posted 14 years ago Permalink
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
ansgar's profile image ansgar posted 14 years ago Permalink
http://forums.mysql.com/

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