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

Announcements

No record found.

News and Announcements icon
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

  • Jie G Profile Picture
    Microsoft Employee on at

    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,286 on at

    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
    307,769 Super User 2026 Season 2 on at

    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

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

  • André Arnaud de Calavon Profile Picture
    307,769 Super User 2026 Season 2 on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans