Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there someone out there with code to create a calendar where after you select a year and month a list of days appears? What I am looking for is similar to what we would normally see on the internet when we click on a calendar object. Does this make any sense?
Something like this?
[Calendar]:
LOAD
year(Date) as Year
,month(Date) as Month
,day(Date) as Day
;
LOAD date(recno()+date#('20061231','YYYYMMDD')) as Date
AUTOGENERATE today()-date#('20061231','YYYYMMDD')
;
Note that I normally don't have a Day field. I just use the Date. Also, I usually define my Year and Month fields like this instead:
[Calendar]:
LOAD
date(yearstart(Date),'YYYY') as Year
,date(monthstart(Date),'MMM YY') as Month
;
LOAD date(recno()+date#('20061231','YYYYMMDD')) as Date
AUTOGENERATE today()-date#('20061231','YYYYMMDD')
;
The first approach allows you to compare the same days across months, or the same months across years. The second approach makes the Month a continuous dimension that includes the Year. It also allows you to use date functions on all your date-related fields. Neither is correct or incorrect. They just have different uses. You can even use both in an application. I've just found myself always using the second approach, and never using the first, and that being most useful for the data I'm playing with.
That worked, but is there a way to make it coorespond with the days of a week? Just like you'd see in a date drop down?
Add this code to John's above to get the days of the week:
weekday(Date) as WeekDay,