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
]]>

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |