Here you go:
function month(vdate)
rval = nil
-- Set up a table of Month names
local months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
if is.datetime(vdate) then
-- Get the month number using datetime.moment
local monthnum = datetime.moment(vdate, "m")
-- Return a table of the Text and Num values
rval = {Text = months[monthnum], Num = monthnum}
end
return rval
end
d = string.datetime("20130513", "CCYYMMDD")
print (month(d).Text, month(d).Num)
Stephen Redmond is CTO of CapricornVentis a QlikView Elite Partner. We are always looking for the right people to join our team.
Follow me on Twitter: @stephencredmond
No comments:
Post a Comment
Note: only a member of this blog may post a comment.