Skip to main content

Notifications

Microsoft Dynamics RMS forum

Calculate First Of Week

Posted on by 35

 

How to get the first day in a week  ( Saturday )  NOT  ( Sunday ) in WeekToDate field DailySalesByRegister.rdl  Report

The defult Function  in SQL ( dbo.fnCalculateFirstOfWeek )

USE [MSPOSPractice]

GO

/****** Object:  UserDefinedFunction [dbo].[fnCalculateFirstOfWeek]    Script Date: 12/15/2012 06:07:29 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER OFF

GO

ALTER FUNCTION [dbo].[fnCalculateFirstOfWeek](@inputDate datetime) RETURNS datetime AS BEGIN return DATEADD(WK, DATEDIFF(WK, 0, @inputDate),  -1) END

 please help me to Modify this script

 

*This post is locked for comments

  • Spencer McCandless Profile Picture
    Spencer McCandless 2,085 on at
    Re: Calculate First Of Week

    I've never used POS 2009,  and there's probably a much more elegant way to do this, but the easiest way to get one day before what its currently returning would be to replace

    DATEADD(WK, DATEDIFF(WK, 0, @inputDate),  -1)

    with

    DATEADD (DAY, -1, DATEADD(WK, DATEDIFF(WK, 0, @inputDate),  -1))

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,802 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,129 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,154

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans