Skip to main content

NAVISION - How To Display Time in Words.

Hi all,

This is nothing most of you would be interested in. This post only show steps about how to Display Time in words in Navision.

If you don't know this, then please go ahead.

The intended readers for this post are the Peoples who have recently joined and are still Learning NAV. Based on a Query from a Friend Via Contact Form.


This post list down the steps and objects that i have used to complete the requirement. I have done it for NAV 2009 Classic Client and As well as on NAV 2013.

Let's Start and see how we can achieve it.

Concept -
---------------------------
1. First thing that came to my mind that Navision Report 1401 Check contain a function which is able to convert Amount in Words. - I will be Referring That.

2. Second Thing that comes to my mind is date actually contain Decimal values separated with a date separator commonly ':'.
---------------------------

What i need to Do?
---------------------------
1. Separate the Date in three parts - Hours, Minutes & Seconds.

2. Create a copy of Standard Function in Report 1401 - FormatNoText, to convert Date in Words.

OR

2. Copying Related Function From Report 1401 Check to My Form & Page.

In Demo i will be Copying Function to My Form & Page but i would suggest to make a copy of the function in 1401 instead of make the form or page clumsy.
---------------------------

**I am not doing it in Report itself as the Report 1401 contain localization which may be be different in your case.

Step 1 - (Breaking Dates in Parts) -

- Created a Form / Page with a input field which will accept Time.

- Create a Button / Action, on click on which the date will be Break into Three parts.

- On Push Action
   1. Check the Input Value.
   2. Convert Time in Text.
   3. Break Time in Hours Minutes and Seconds.
   4. Convert Time from 12 Hours to 24 Hours.

CODE
----------------------------------------------------
IF InputTime = 0T THEN
  ERROR('Input Time Value');

TimeInText := FORMAT(InputTime);                  

EVALUATE(TimeParts[1],COPYSTR(TimeInText,1,2));      
EVALUATE(TimeParts[2],COPYSTR(TimeInText,4,2));      
EVALUATE(TimeParts[3],COPYSTR(TimeInText,7,2));      

IF COPYSTR(TimeInText,10,2) = 'PM' THEN
  TimeParts[1] += 12;
----------------------------------------------------
Where -
InputTime - Time.
TimeInText - Text (12).
TimeParts - Decimal (Array Dimension 3).

Step 2 - Copying the Related Function, Variables & Text Constants from 1401 to my form/Page.

I will copy following functions -

1. FormatNoText (Renamed the Function to - FormatNoTime)
2. AddToNoText
3. InitTextVariable

Copying Following Global Variables -
OnesText
TensText
ExponentText

Copying Text Constants -

1. Text026 TO Text028
2. Text032 TO Text058

Below are the Changes that i have done in the Standard Function Copied From Report 1401- 

**Only Changed Code Shown in Below Images

Function FormatNoText (Standard) VS FormatNoTime (Customized)

Removed Code in Customized Function where Currency Related Constants are added like Rupee for INR.

Other than Highlighted Part other Code Remain Same.


Function InitTextVariable -

Removed Code in Customized Function. Other than Highlighted Part other Code Remain Same.


4. Now i will append code in Push action of same button as shown below -

CODE
----------------------------------------------------
CLEAR(TimeinWords);
InitTextVariable();                    
FormatNoTime(Output,TimeParts[1],'');  
TimeinWords += Output[1] + ' HOURS ';
FormatNoTime(Output,TimeParts[2],'');
TimeinWords += Output[1] + ' MINUTES ';
FormatNoTime(Output,TimeParts[3],'');
TimeinWords += Output[1] + ' SECONDS ';
MESSAGE(TimeinWords);
----------------------------------------------------
Where - 
TimeinWords - Text (90)
Output - Text (80) - (Array Dimension 2).

What this code does?

 > Clear the Text Variable.
 > Initialize the Text Variables.
 > Do the Conversion for Each Part and Append that to a Text Variable.

Let's Try Executing the Form & Page. Below the screens running the Form & Page in 2009 & 2013.

Input Window -


Output Window -



Objects can be Downloaded in Text & FOB From My Skydrive.
File Name - Convert Time in Words.zip

I hope you find the post useful and let me know the feedback of such basic Navision post on the Contact form or as a comment to post.

Stay Tuned for More.

Regards,
Saurav Dhyani
www.sauravdhyani.com

Comments

  1. Sir, As I want to convert Numbers to Text. for ex, if i give 1 output should be One and so on. can i have code for that...

    ReplyDelete

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.