Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Using Value Lists for Month and Year


This topic is 7234 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

This seems a simple idea, but I can't figure it.

I want to create two fields called 'Month' and 'Year' for data entry via Value Lists (the first listing Jan thro' Dec, the second listing 2005, 2006 and 2007). This is how it is done on those holiday booking web sites.

How do I configure the fields and how do I extract the information from them to form a valid date (assuming the first of each month)?

Posted

Create two value lists, one containing the months and one containing the years. Format each field to display the appropriate list, then create a calculation field with a date result of

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( Month; 1; Year ) )

Posted

Month should be text and Year can be number or text. Neither should be dates, because they are only a portion of the date.

Posted

Just tried it and no matter what month I type into the 'Month' field I get a date returned 1/12/2004 in the calculation field when entering '2005' in the 'Year' field and 1/12/2005 if I enter 2006 as the year.

Posted

I've tried typing either Aug or August. It is set up as a text field and I would prefer my users to enter it this way rather than a month number, which can cause confusion when dealing with different years (i.e. Apr - Mar or Jan - Dec).

Posted

If you're going to make a value list - and I presume you will, considering the forum section - you will have to settle on one or another. Let us know which one will it be, and we'll adjust the calc to fit.

Posted

Doh!

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( "JanFebMarAprMayJunJulAugSepOctNovDec"; Month; 0; 1 ) + 2) / 3; 1; Year ) )

or

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( ValueListItems( Get(FileName); "Months" ); Month; 0; 1 ) + 3) / 4; 1; Year ) )

I omitted the conversion, sorry!

Posted

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( ValueListItems( Get(FileName); "Months" ); Month; 0; 1 ) + 3) / 4; 1; Year ) )

Caution Caution, will only work with abreviations with the lenght of 3 stuffed in the valuelist ... should be reworked in case full words of variable length are required in the popup.

The things are getting tricky when several languages are used based on system settings - Two valuelist are then required one with the names from the systemsetting for the popup and one similar with trailing @@@@'s to make the positioning the start of each word multiplications of the longest month names length. To get the system settings word has the list to be build via the MonthName function.

The reason for going thru all these measures is that this pseudo Case'ing is slightly faster than the genuine.

--sd

Posted

( Position( "JanFebMarAprMayJunJulAugSepOctNovDec"; Left ( Month ; 3 ) ; 1; 1 ) + 2 ) / 3

Not solving the language problem, but allows for the two alternatives mentioned here.

This topic is 7234 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.