Skip to Content

Clear Time Column

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 05, 2015 at 01:05 PM

    Hi Andreas;

      Have you tried ...

    String   ls_data

    SetNull ( ls_data )

    DC.SetColumn ( <dt_column> )

    DC.SetText ( ls_data )

    Regards ... Chris

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Christopher Harris

      <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.  😳

  • avatar image
    Former Member
    Jan 05, 2015 at 07:59 PM

    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...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 12, 2015 at 05:50 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded