date function | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

date function

how can I return the last date of last month? Today: 7 July Expected return: 30 jun

SELECT DATEADD(d,DATEDIFF(d,DAY(GETDATE()),GETDATE()),0)

Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
Thanks alot. It works. Although I actually need the vb code, I found a walkaround.
Good to hear that. I’ve actually realised after my posting that you’ve asked about Reporting Services. Isn’t the VB code very similar and something like:
DATEADD("d",DATEDIFF("d",DAY(NOW()),NOW()),0) ? —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
]]>