AW: [personal kdb+] using temporal .month method in a user defined function

<o:p> </o:p>

You cannot use dot inside a lambda function to access the month type.<o:p></o:p>

Instead you need to cast to the month type.<o:p></o:p>

<o:p> </o:p>

months_bw:{x;y - `month$y }<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

Von: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] Im Auftrag von jcw
Gesendet: Sonntag, 6. Januar 2013 23:45
An: personal-kdbplus@googlegroups.com
Betreff: [personal kdb+] using temporal .month method in a user defined function<o:p></o:p>

<o:p> </o:p>

Newbie question:<o:p></o:p>

I’m attempting to use temporal data type methods (java term, sorry) in a function, but I’m getting an error:<o:p></o:p>

q)d:2012.10.01<o:p></o:p>

q)e.2012.11.01<o:p></o:p>

q)d.month<o:p></o:p>

2012.10m<o:p></o:p>

q)e.month<o:p></o:p>

2012.11m<o:p></o:p>

q)months_bw{[x;y]x.month - y.month}<o:p></o:p>

q)months_bw[x;y]<o:p></o:p>

`y.month<o:p></o:p>

<o:p> </o:p>

Not sure how to resolve this, as the function parameter is clearly a date:<o:p></o:p>

q)type e<o:p></o:p>

-14h<o:p></o:p>

<o:p> </o:p>

Any thoughts would be greatly appreciated!<o:p></o:p>

<o:p> </o:p>

Thanks<o:p></o:p>


Submitted via Google Groups

http://code.kx.com/wiki/FAQ

. notation does not work with locals

use `month$

   Attila

Interestingly, dot notation does work within the select/exec constructs

q){exec x.month-y.month from ( (),x;(),y)}[2012.11.01;2012.10.02]

,1

q){exec x.month from ( (),x)}[2012.11.03]

,2012.11m

But in general casting to `month is best