Text Display Object Dates


#1

I’m creating a form that needs to display a date (“DOB”). I’ve set the output format to DD/MM/YYYY in the datasheet. However, when creating a new Text Display object, dates are a number (ie 2439706). I’ve looked at the datepattern( function, but cannot for the life of me workout where to put my DOB field so it will work in the datepattern( function.

It would really be useful in the documentation to have one example for simpletons like myself that tells you where to place your fieldname and what formatting it should be in ie “” «», etc.

Many thanks!


#2

Make sure the Text Display Object is set to formula in the Options panel and then in the Formula panel enter datepattern(DOB,“DD/MM/YYYY”).


#3

Many thanks! It’s annoying when it’s that simple!


#4

In the formula panel of your object, put datepattern(DOB,“MM/DD/YYYY”)


#5

Simon,

The Help wizard entry for the datepattern( function includes these examples, among others:

datepattern(today(),"mm/dd/yy") ☞ 8/9/12
datepattern(today(),"MM/DD/YY") ☞ 08/09/12
datepattern(today(),"mm/dd/yyyy") ☞ 8/9/2012
datepattern(today(),"Month ddnth, yyyy") ☞ August 9th, 2012
datepattern(today(),"dd-MON-yy") ☞ 9-AUG-12
datepattern(today(),{DayOfWeek, Month ddnth, yyyy}) ☞ Thursday, August 9th, 2012
datepattern(today(),{Qtr "Quarter" yyyy}) ☞ 3rd Quarter 2012
datepattern(today(),"YYYYMMDD") ☞ 20120809

#6

The examples from the Pan X Help contain the function today(), but you can use any other date function (e.g. now()) there — or the name of your date field.

datepattern(yourdatefield,"mm/dd/yy")

Simon asked about quotes around field names, too. Here is the documentation about that:


#7

Thank you all. The challenge for me as one who doesn’t code is that I don’t really know functions, variables etc, and although datepattern(today(),"mm/dd/yy") looks easy, it doesn’t to a non-coder. I tried the following:

datepattern(field(),"mm/dd/yy")
datepattern("field"(),"mm/dd/yy")
datepattern(«field»(),"mm/dd/yy")

It never dawned on me that the () is part of the today function and also needs to be removed. Even the Formula workshop did not give me an error that I could understand. I know I lack a lot of understanding on this (I am doing some learning around this to improve!), but to have a function example in the function description that shows where the field goes in the function/formula, would prove very helpful to new users and non-coders. The “Using Fields in a Formula” also doesn’t help in knowing where to put the field.

I’m enjoying using Panorama X and think the documentation and tutorials and videos are excellent. I do think that they could be improved in this regard.

Many thanks!


#8

I’m sure @kjm is aware and just mistyped, but now() is not a date function, it is a time function. So it should be used with timepattern(, not datepattern(. But his most important point stands, you can use any date field with the datepattern( function.

The rule is that function names always end with a (. So if you see ( on the end, like today(), sin(, upper(, etc, that is a function. The ( must be immediately after the function name, with no space. So today(), not today (). This isn’t really a Panorama invention, almost every programming language uses this convention of ( at the end of function names.

By the way, function names are not case sensitive, so today(), TODAY() and Today() are all allowed. But field and variable names are case sensitive, so if you have a field named Birthday, you must spell it exactly that way, and not BIRTHDAY or birthday.

There is no special place for fields. A field can be used anywhere a value is allowed, so can a function, or for that matter a complete formula. So if you wanted to display the date one month from today, you could use this formula:

datepattern(monthmath(today(),1),"mm/dd/yy")

Or if you wanted to display the date 90 days after a person’s hiring date, you could use this formula.

datepattern(HireDate+90),"mm/dd/yy")

So it’s not just a question of “where does the field go?” – a field is just one type of value that can occur in a formula.

I don’t disagree with your point that it would be nice if every function had detailed documentation of every possible permutation and use, but it’s just not possible. There are already 4 million characters of documentation for Panorama X! So what you need to do is learn the basic rules about how formulas are put together, then once you know the rules, you’ll be able to apply them to every function you use.


Advanced Note: Most programming languages only allow letters and numbers in field and variable names. Panorama, however, allows any character in a field or variable name. For example, you could set up a field with a name of P/E Ratio. But what if you use this field in a formula, like this?

P/E Ratio * 2

This formula will result in an error, because the formula parser will think it means P divided by E, then it won’t know what to do with Ratio. It thinks this name is 4 separate elements. To tell the formula parser that this is a single name, not a series of separate elements, you must surround the name with the « and » characters (called chevrons), like this:

«P/E Ratio» * 2

Since using this technique a field or variable name could contain any character, you could even use a ( symbol in a field or variable name, then use it in a formula like this:

«today()»

So this formula means "get the value of the field or variable named today(), which is different from using the today() function, which is the same but with no chevrons.

today()

Of course this is extraordinarily confusing, so I don’t recommend giving a field or variable a name like this. In fact, I almost always stick to field and variable names with only letters, so I don’t need to ever use chevrons and any possible confusion is avoided. Remember, in Panorama X you can give a field a name with only letters, while still giving it a title that will be displayed in the data sheet with other characters. So you could make a field named PERatio, with a title of P/E Ratio.

P.S. The one character that you cannot put into a field or variable name is »!