Tips.gif (2048 bytes)

 

 

 

 

 

Calculate, convert month end Values MS SQL Server

This will calculate and convert a date to the last day of that month in SQL Server

"--" is a remark that doesn't execute

select date_ent,

dateadd(dd,-1,

convert(char(2),
datepart(mm,
-- begin this is next month
dateadd(dd,20,convert(char (2),datepart(mm,date_ent))
+"/15/"+convert(char (4),datepart(yyyy,date_ent)))
-- end this is next month
))+"/01/"

+

convert(char(4),
datepart(yyyy,

dateadd(dd,20,convert(char (2),datepart(mm,date_ent))
+"/15/"+convert(char (4),datepart(yyyy,date_ent)))

)))

from ITEM_LEDGER-- JDE FILE F4111
--where date_ent > "03/31/2001" // use if needed

Return to Mini Solve Products and tips