Skip to main content

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Thank you, Ingo!
I will have a look at this after the summer. (This is my last day at work before summer vacation.)

/ Jenny

 


Author: JennySandqvist (jenny.sandqvist@adm.umu.se)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Note: Ingo's example code would populate format and deformat triggers for all fields, and you might only want to apply the change to fields with the required data type. Also, you might want to consider external variations (in UXFIELD). I would recommend doing a clean up and making a backup first if you do this.

Regards,
David


Author: dakerman (david.akerman@compuware.com)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Hi Dakerman

You are right :-)

Thanks for clearifying this.

Ingo

 

 

 


Author: istiller (i2stiller@gmx.de)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Hi Jenny,

For Date-fields I do not prefer to use the field syntax property ENT() . 

For Date-fields (dataype D) you can use 1 field LAYOUT property:  DIS(yyyy-mm-dd).

Or you can use another Layout format like DIS(yymmdd) or DIS(yyyymmdd).

You can also apply Field Layout format for datatypes DateTime and Time .

Jip

 

 


Author: Jip Westerman (jipwesterman@gmail.com)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Are your sure, that ENT is the rigth way to tell UnifAce which entry formats fopr DATE-fields are allowed? :-)

From documentation:

If you use the ENT shorthand code for data entry, use the ENT(DMY) format if you want 4-digit year input (for example, 01-01-1997). The format ENT(YMD) only permits the entry of two digits (for example, 97-01-01).

So if you need other format then in DIS defined, you have to code the FORMAT/DEFORMAT-trigger. With the use of globale procedures, this can be done in an elegant way :-)

Ingo


 


Author: istiller (i2stiller@gmx.de)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Thank you for your reply, Ingo!

I have also read this line in the Uniface Library:
If you use the ENT shorthand code for data entry, use the ENT(DMY) format if you want 4-digit year input (for example, 01-01-1997). The format ENT(YMD) only permits the entry of two digits (for example, 97-01-01).
And that is why I was so surprised that ENT(ymd) still did allow a 4-digit year input (but only when I type it all in a row, yyyymmdd, not yyyy-mm-dd).

Maybe we will have to consider the use of global procedures after all, even though it would mean that we would have to put code (at least calls) into a lot of forms...

/ Jenny

 


Author: JennySandqvist (jenny.sandqvist@adm.umu.se)

Date field properties

Author: jenny.sandqvist@adm.umu.se (JennySandqvist)

I have a problem with date fields. Up until now we have allowed two different ways of typing dates, yymmdd and yyyy-mm-dd, but now we have decided to allow a third way of typing, yyyymmdd. The data type in the field is Date and the widget type is EditBox. We use a template in the Syntax Field Property that in shorthand terms reads: ENT((yymmdd) (yyyy-mm-dd)), MUL.
When typing yyyymmdd the date gets all mixed up, for example if I type 20110621 (June 21 2011) it becomes 20211106 (November 6 2021). We can of course fix it with code in the deformat trigger, but since date fields are used in hundreds of forms we are hoping to be able to fix the problem just by changing the template for the (Syntax) Field Property.

I can´t seem to make all three ways of typing work at the same time:
If I remove the ENT(yymmdd) (and just keep ENT(yyyy-mm-dd)) I can type yyyymmdd and yyyy-mm-dd, but not yymmdd (it gets mixed up).
If I use ENT(ymd) or ENT(yymmdd) I can type yymmdd and yyyymmdd, but not yyyy-mm-dd (the on-error trigger gets activated).
Is there a way to make all three ways work with the same property (without coding) or is it impossible?

Hi Jenny

About the globale procedures:

Do you have allready code in the DEFORMAT-trigger?

If not, there is a very easy solution to populate the trigger. Just create a from with entity UCFIELD painted in it. Code a loop over all occurences in UCFIELD.

You can code a more complex procedure if required. e.g. check for a place to put new new CALL if there is allready code in the trigger

Ingo

 

ENTRY LP_POPULATE
  $FMT_TRIGGER$ ="call SF_FORMAT(%%"%%")"   ; Whatever you want call
  $DFMT_TRIGGER$="call SF_DEFORMAT(%%"%%")" ; Whatever you want call
  clear/e "UCFIELD"
  U_VLAB.UCFIELD/init="your_modell"
  retrieve/e "UCFIELD"
  v_I=0
  WHILE(1)
    v_I=v_I+1
    setocc "UCFIELD",v_I
    IF($status<=0|$dbocc(UCFIELD)<=0) BREAK
    IF(P_FORMAT.UCFIELD  ="") P_FORMAT.UCFIELD  =$FMT_TRIGGER$
    IF(P_DEFORMAT.UCFIELD="") P_DEFORMAT.UCFIELD=$DFMT_TRIGGER$
  ENDWHILE
  store/e "UCFIELD"
END

 


Author: istiller (i2stiller@gmx.de)