Can you explain better?
When you refer to "max month in the date field" do you intend the max month inside the entire table?
For example (with date in yyyy/mm/dd format):
--------------------------
01 02 03 ... 12 Date YOY
--------------------------
x1 y1 z1 ... k1 2001/09/12 ?
x2 y2 z2 ... k1 2003/03/04 ?
--------------------------
You simply use month 09 for the first row and 03 for the second (the month in th data field of the row), or the max month is 09 for both rows (09 > 03) or the max month is 03 for both rows (cause the data containing the 03 month is greater than the data containing 09 month)?
The solution depends on what you intend.
Bye
Main Topics
Browse All Topics





by: bonjour-autPosted on 2003-04-16 at 08:42:56ID: 8341800
If you want to do it directly in SQL:
])<1,0,1)+ [02]*IIf(M onth([targ etdate])<2 ,0,1)+[03] *IIf(Month ([targetda te])<3,0,1 )+[04]*IIf (Month([ta rgetdate]) <4,0,1)+[0 5]*IIf(Mon th([target date])<5,0 ,1)+[06]*I If(Month([ targetdate ])<6,0,1) AS YOY
SELECT datecalc.*, [01]*IIf(Month([targetdate
FROM datecalc;
e.g. for half year
not very elegant, but it works
one could put the Iif-Sequence to a Public Function
Regards, Franz