Adding Date Picker (Calendar Selector) to Form Date Field

Hi. I’m brand new to Panorama X (moving from FileMaker). So far, so good. Is there a way to add a date picker to a form’s date field(s)? I use these frequently because they make it easier to select the correct date. Obviously, having to manually enter a date value is not a tremendous burden, but pickers are pretty handy. Thanks.

It’s a small project to build one from a calendar matrix.

I just built that one, using the construct menu, and then making some modifications.

Dave, While what you’ve done is pretty easy, the reality is calendar pickers are commonly seen as ‘tools’ that are already pre-built. Your demo does show how easy it can be, but I’m imagining that many newer users might appreciate a few choices to pick from and move on with a choice. It was not a stretch to imagine some amazing piece of work suddenly appearing from one of our over the top talented, too much time of their hands professionals. We have one guy who has 4 letters in his name and it starts with G and he regularly blows us away with his talents for this kind of stuff. :slight_smile:

1 Like

Put the pressure on me why don’t you.:blush:

Anyway, here is my approach to the problem…

The form requires these objects set as noted:

Three Popup Menu Objects:
    1. The year popup - Data set as theYear and Mode to Formula:
            arrayfilter(rep(cr(),20),cr(),{seq()+val(datepattern(today(),"yyyy"))-11})
        Procedure Code:
            theMonth="January"
            theDay="01"
            showvariables theMonth, theDay

    2. The month popup - Data set as theMonth and Mode to Formula:
            arrayfilter(rep(cr(),11),cr(),{datepattern(date(str(seq())+"/1/2017"),"Month")})

    3. The day popup - Data set as theDay and Mode to Formula:
            arrayfilter(rep(cr(),monthlength(date(theMonth+" 1, "+theYear))-1),cr(),{pattern(seq(),"##")})

    4. An optional Text Display Object with Mode to Formula:
            theMonth+" "+theDay+", "+theYear

Add this code to your .Initialize procedure to preset the popups:
    makefileglobals theYear=datepattern(today(),"yyyy"),
    theMonth=datepattern(today(),"Month"),
    theDay=datepattern(today(),"dd")
    showvariables theYear,theMonth,theDay

The year popup will automatically display a list of years 10 years before this year to 10 years past this year. The month popup will display a list of the 12 months of the year while the day popup will display the proper number of days for the chosen month and year.

You can change the range of years by adjusting the year popup formula. The number of years is determined by the value entered into the rep( function (in the above case the 20 will list 21 total years since the repeat is generating the separators which is always 1 less than the total array elements.) The range is determined by the value added or subtracted from the current year value (in the above case it is set to -10 so it starts the year list 10 years previous to the current date).

1 Like

What happens when the day is set to the 30th, and the user selects February?

The day popup goes blank and the user would have to make a new selection from that popup.

You could also add a trap to the Procedure pane of the month popup object to reset the day to the last day of the selected month if the current day is beyond the range for that month.

if val(theDay)>monthlength(date(theMonth+"/1/"+theYear))
theDay=monthlength(date(theMonth+"/1/"+theYear))
showvariables theDay
endif

I am trying to do the same as dtwalsh was doing. I am looking for a date picker that is part of the date field - the same type as I used in Filemaker. I can’t find one and I was hoping that since 3 years has passed since this was posted, that there would be such a feature.

Maybe something has changed in Panorama because I can’t seem to get either of the above mentioned methods to work properly. I am not a programer so I am most likely doing something wrong. With the second method by Gary, my month popup field shows January 12 times and nothing else. He says to add code to the .Initialise procedure - where do I find that?

The “12 Januaries” problem exists, because Gary’s code (from Dec 16, 2017) was written for U.S. date format, and it seems you are using a different system setting.

I made a quick test, followed Gary’s instructions and got the same problem; I had to change the formula of the “theMonth” popup from

arrayfilter(rep(cr(),11),cr(),{datepattern(date(str(seq())+"/1/2017"),"Month")})

to

arrayfilter(rep(cr(),11),cr(),{datepattern(date(str("1/"+seq())+"/2017"),"Month")})

to work with my German system settings for the date format.

You are asking where you find an “.Initialize” procedure. You create it: Make a new procedure and name it “.Initialize”. Paste Gary’s code there. Then the three variables are automatically defined when you open the database.

The “.Initialize” procedures are documented here:

Fantastic. Thanks for your help, it works perfectly now.

Following on from this thread, and no doubt revealing how much I struggle with dates…

I want to review data in my database based on the date I entered the data, or on the date to which the data refers. I have designed a form with a list of the dates on which data was entered, and I can select a date in the table, and then successfully search the database for the data with this date.

The second situation is proving more difficult. I have displayed that information using the format July 2020. Therefore, I want to enable the user to select the date in this format. Whether I do it from a list created from the database, or from a drop down menu as per Gary above, I create a variable with the month in word format. I can’t figure out how to then search the data using the word. It’s clearly possible because I can do it from the Search function in the database, but it doesn’t (seem to) work in the same way in a programme. date() doesn’t seem to be the answer…

Let’s say you have variables named Month and Year, and the field is named EntryDate. If Month contains the full spelling of the month, and year is the full 4 digit year, then you could search for records from that month and year like this.

Select datepattern(EntryDate,"Month yyyy") = Month + " " + Year

Your condition is just a true/false formula. You want to do a comparison that will be true for the records you want, and false for those you don’t, so you make the datepattern( function produce text in the same format as the text you get from your variables.

Terrific. Thanks

What would formula be for popup to display “DayofWeek”? What would I need to add to initialize?

When I set up popups for year, month and day, they work fine; however, text object display only shows current date. How do I have it show date selected with popups?