cancel
Showing results for 
Search instead for 
Did you mean: 

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

kuentang
New Contributor

 

You cannot use dot inside a lambda function to access the month type.

Instead you need to cast to the month type.

 

months_bw:{[x;y](`month$x) - `month$y }

 

 

 

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

 

Newbie question:

I'm attempting to use temporal data type methods (java term, sorry) in a function, but I'm getting an error:

q)d:2012.10.01

q)e.2012.11.01

q)d.month

2012.10m

q)e.month

2012.11m

q)months_bw{[x;y]x.month - y.month}

q)months_bw[x;y]

`y.month

 

Not sure how to resolve this, as the function parameter is clearly a date:

q)type e

-14h

 

Any thoughts would be greatly appreciated!

 

Thanks

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/personal-kdbplus/-/inuqaYXgUSYJ.
To post to this group, send email to personal-kdbplus@googlegroups.com.
To unsubscribe from this group, send email to
personal-kdbplus+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/personal-kdbplus?hl=en.

2 REPLIES 2

Attila
New Contributor
http://code.kx.com/wiki/FAQ

. notation does not work with locals
use `month$
   Attila

TerryLynch
New Contributor II
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