Categories
Dynamics NAV HOW TO Microsoft

HOW TO calculate the Day of the Year number in C/SIDE

You can calculate the Day of the Year number in C/SIDE by the difference between the date (in my example I use the current date defined by the operating system using the function TODAY) and the first day of year of the date using the CALCDATE function. You need to add 1 to the result to include the day of the date that you are using.

HOW TO calculate the Day of the Year number in C/SIDE

[sourcecode lang=”Cside”]
Number := TODAY-CALCDATE(‘<-CY>’,TODAY)+1;
[/sourcecode]

If you need it as Text you need to convert it using the FORMAT function
[sourcecode lang=”Cside”]
String := FORMAT(TODAY-CALCDATE(‘<-CY>’,TODAY)+1);
[/sourcecode]

Did my HOW TO help you? Leave a reply.

Categories
Dynamics NAV Microsoft Tips & Tricks

Tips & Tricks – Trim method in Microsoft Dynamics NAV (Microsoft Business Solutions-Navision)

My Tip & Trick help you to implement Trim function in C/AL for Microsoft Dynamics Nav.

Trim

Removes all white-space characters from the start and end of a string.

You can use the C/AL function DELCHR with the following syntax:

NewString := DELCHR(String [, Where] [, Which])

So, you can use the following code:

String := DELCHR(String,'<>',' ');

TrimStart or LTrim

Removes all white-space characters from the start of a string.

String := DELCHR(String,'<',' ');

TrimEnd or RTrim

Removes all white-space characters from the end of a string.

String := DELCHR(String,'>',' ');

NOTE:
Since “spaces” are used as the default for Which, we can skip the second parameter and write code like this:

String := DELCHR(String,'<>');

Do you think that my Tip & Trick is useful? Leave a reply.