web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Month Function

(0) ShareShare
ReportReport
Posted on by

i have wrote this function for date...... used in daily cash accounting which is working perfectly, now i am going to develop monthwise cash accounting. can anyone please help me out how can i convert this date funtion to month.

DECLARE @OpeningAmt NUMERIC(19,2), @Pdate date

--return

SET @date= DATEADD(date, -1,@fromdate)

if (isnull(@FromDate, '1900-01-01') <> '1900-01-01')
begin
Declare @Opening table
(
TENDERTYPE int
, TenderName varchar(500)
, Opening numeric(19,2)
, NetSales decimal(28,2)
, DepositAmt numeric(19,2)
, ExpenseAmount numeric(19,2)
, Income numeric(19,2)
, Payments numeric(19,2)
)

insert into @Opening
EXEC [MtqRpt_TenderTotalsDynamic]
@PDataAreaID = @PDataAreaID,
@StoreId = @StoreId,
@FromDate = <10900-01-01>
@ToDate = @Pdate
@Terminal = @Terminal

select @OpeningAmt = sum( NetSales + Income - (DepositAmt + ExpenseAmount ) )
from @Opening
where TENDERTYPE = 1
end

*This post is locked for comments

I have the same question (0)
  • Jie G Profile Picture
    on at
    RE: Month Function

    Hi,

    If you mean how to get a date monthly, you can still use DATAADD, specifying the first argument as mm. Reference: docs.microsoft.com/.../dateadd-transact-sql  

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: Month Function

    Hi AXDYNAMICS,

    To get beginning of the month you can use

    SELECT DATEADD(DAY,1,EOMONTH(@mydate,-1))


    and for end of the month

    SELECT EOMONTH(@mydate)
  • André Arnaud de Calavon Profile Picture
    300,289 Super User 2025 Season 2 on at
    RE: Month Function

    How is this SQL script related to Microsoft Dynamics AX? What exactly should it do? If it is not related to Microsoft Dynamics AX, you can better use a SQL forum.

  • Community Member Profile Picture
    on at
    RE: Month Function

    what i will write for if condition where date used 1900-01-01?

  • André Arnaud de Calavon Profile Picture
    300,289 Super User 2025 Season 2 on at
    RE: Month Function

    I'm sorry, but I really don't understand what this question is about. The title has something in it called 'month'. You are on a Dynamics AX forum asking a question about possibly an SQL script and now you ask a question about a date on January 1, 1900? I'm lost here...

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Aayyon Das Profile Picture

Aayyon Das 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans