Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

Calculate First Of Week

(0) ShareShare
ReportReport
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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans