cancel
Showing results for 
Search instead for 
Did you mean: 

Clear Time Column

Former Member
0 Kudos

PowerBuilder 12.5

I have a datetime column which represents time with eidtMask hh:mm and format hh:mm.  If I write something to this field then I can't clear it so as to become null.  It will show 00:00 and treat it midnight.  In some cases I have written code to handle this situation (user selects all and presses backspace), but I would like to know if there is an easy way of doing this.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Andreas - I once worked on a PB v6.5 app (Classic/PFC) where users entered time-duration values (00:01:30 = 1 minute, 30 seconds, for example) and like you, the users wanted the input field to be empty if there was no value. For speed/productivity reasons they also wanted be able to enter values like "15", "1m", "90", or "1h" (for 15 seconds, 1 minute, 1 minute 30 seconds and 1 hour, respectively). Edit masks were far too inflexible, so we used a simple edit column object and interpreted/validated the input in the ItemChanged event and formatted the validated input value in a standard manner for presentation back to the user.

If I recall correctly, the actual time-duration data columns were defined as 32-bit unsigned longs in the database table, so we created a formatted string representation of each time duration (long) value in the DW's SELECT statement and that is what the user interaction affected, then we updated the actual long integer table column value via the validation code. Since we were using the PFC, we created a DW service object to handle the details, coded it once and used it in dozens of places throughout the app with minimal code.

We didn't have to resort to capturing keystrokes or try to coerce the edit mask style into doing things it wasn't capable of doing. Most importantly, our user community was very happy their request was heard and addressed. I don't see any reason a similar approach wouldn't work in your situation where you're working with time-of-day values, especially if you are using some kind of object framework in the app.

Food for thought.

Former Member
0 Kudos

Do you also require that the field is blank when the value is null? It is achievable but I think not an easy way.

Some options that you can do:

1. Provide the user with a pop-up menu to clear or set the columns value to null.

2. Capture the keystrokes: delete, backspace and spacebar because these keys can clear the field's value, so if it's the "last key" that the user had pressed before the itemchanged event occured, then check the field's value, if it's 00:00, then set it to null.

3. If you could treat all 00:00 value as null, then on itemchanged event, just check the value and set it to null when it is 00:00.

Just my 2 cents...

Former Member
0 Kudos

Hi Andreas;

  Have you tried ...

String   ls_data

SetNull ( ls_data )

DC.SetColumn ( <dt_column> )

DC.SetText ( ls_data )

Regards ... Chris

Former Member
0 Kudos

Sorry, I think I was misunderstood.  I want the user to be able to clear the field, not me by code.

Former Member
0 Kudos

   Unfortunately, once you have a "mask" in place - the "Empty is NULL" option is not available to clear the column just by the user backspacing or Select / Deleting the data in the edit control. You would need to provide some PowerScript assistance.

  In PB 12.6 you do have a new "Use Format" option on the DW column's that can make the EditMask disappear (hence your 00:00) - but you would have to upgrade your PB version.

  Even though an EditMask is in vogue - I think that we should still have an "Empty is NULL" option.

Former Member
0 Kudos

Hi Andreas.

I usually place a button in my datawindow which sets the date field to null. This can mean a lot of work if you have many date fields, but for the end user it's very useful,

Andreas.

Former Member
0 Kudos

I don't mean to hijack this thread, but I have a question for Chris.  This is the second thread that I've seen where you reference the "new" "Use Format" property in 12.6.  Are you referring to a different property than the one below or am I miss understanding?

This feature has been around for quite some time (this screenshot is from PB 9.0).  I'm not being an arse, just trying to understand the reference.

Thanks

Former Member
0 Kudos

<my bad> you are correct ... Please disregard <duh>!  

I was thinking of something else plus working on only one coffee when I answered that one.