Time without seconds

RemcoRemco Member Posts: 81
edited 2014-09-08 in NAV Three Tier
Hi,

Is it possible to show only hours and minutes in a Time field on a Page. So the SmallDateTime Datatype of SQL.
On a form you can fill the format property, but on a page this is not possible.

So not fill it with code but just fill it manually and then only show hours and minutes.

Comments

  • udayrmerudayrmer Member Posts: 171
    If it is done with form, please try it by transforming to page
    Uday Mer | MS Dynamics NAV Techno-Functional Consultant
  • mfabianmfabian Member Posts: 187
    Page: TimeVar-Field - Source Expression.

    Example: You have a Time-Field "Starting Time" which should be displayed as "12:59":

    Instead of entering Source Expression: "Starting Time"
    Enter Source expression: FORMAT("Starting Time", 5)

    But before you do so, make sure you save the CaptionML as NAV will replace your Caption with something like "<Control1000000009>"
    With best regards from Switzerland

    Marcus Fabian
  • vaprogvaprog Member Posts: 1,140
    With Fabian's solution the filed becomes non-editable.

    This is just one of the many features Microsoft kicked for no (apparent) reason. If at least they had kept the OnFormat trigger ...

    To make it editable, you have to declare a global Text variable and include it in the dataset. Then OnAfterGetRecord you need to assign to it using FORMAT. OnValidate you need to evaluate your text to your time field and reformat you text variable. If you want to get the TIME-functionality (entering t (or your localized version) to get the current time), you will have to call the corresponding function in Codeunit 1 (MakeTimeText).

    The length of the time field in the page will correspond to the declared length of the text variable. This alone might turn the balance in favor of the more cumbersome text variable approach.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    vaprog wrote:
    With Fabian's solution the filed becomes non-editable.

    The length of the time field in the page will correspond to the declared length of the text variable. This alone might turn the balance in favor of the more cumbersome text variable approach.

    Thx for the info, could you explain more this last statement?
  • vaprogvaprog Member Posts: 1,140
    The visual size of the textbox on a page is related to some extent to the data type of it's source expression. Just try it out, but keep in mind that NAV also tries to format the page in two columns, so more than just the data type alone is taken into account to determine the final size of the textbox.
Sign In or Register to comment.