Categories
Dynamics NAV HOW TO Microsoft VB.NET Visual Studio

HOW TO calculate the weekday name in RDLC

To calculate the weekday name in RDLC you can use a combination of two Visual Basic functions:

  1. DatePart
    Syntax

    DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
    

    firstdayofweek is an Optional parameter and the Default value is 1 (Sunday).
    firstweekofyear is an Optional parameter and the Default value is 1 (January).

  2. WeekdayName
    Syntax

    WeekdayName(weekday[,abbreviate[,firstdayofweek]])
    

    abbreviate is an Optional parameter. A Boolean value that indicates if the weekday name is to be abbreviated.
    firstdayofweek is an Optional parameter and the Default value is 1 (Sunday).

  3. HOW TO calculate the weekday name in RDLC

    CORRECT RESULTS
    [sourcecode language=”VB”]
    =WeekDayName(DatePart("w", Fields!CurrentDate_System.value,0))
    =WeekDayName(DatePart("w", Fields!CurrentDate_System.value,0,0))
    [/sourcecode]

    WRONG RESULTS
    [sourcecode language=”VB”]
    =WeekdayName(DatePart("w", Fields!CurrentDate_System.Value))
    =WeekdayName(DatePart("w", Fields!CurrentDate_System.Value),false,0)
    [/sourcecode]

    Did my HOW TO help you? Leave a reply.

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.