Re: SQL month riddle - most efficient way?
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 03/13/04
- Next message: Andrew John: "Re: WITH ENCRYPTION"
- Previous message: John Bell: "Re: coding for no blocking or deadlocks."
- In reply to: Nathon Jones: "SQL month riddle - most efficient way?"
- Next in thread: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Reply: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Reply: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 13 Mar 2004 08:25:53 -0000
Here is the query you wanted, assuming you have two SMALLDATETIME/DATETIME
columns in your table. No parameters required.
SELECT *
FROM SomeTable
WHERE DATEADD(MONTH,DATEDIFF(MONTH,0,CURRENT_TIMESTAMP),0)
BETWEEN dt1 AND dt2
-- David Portas SQL Server MVP --
- Next message: Andrew John: "Re: WITH ENCRYPTION"
- Previous message: John Bell: "Re: coding for no blocking or deadlocks."
- In reply to: Nathon Jones: "SQL month riddle - most efficient way?"
- Next in thread: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Reply: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Reply: Nathon Jones: "Re: SQL month riddle - most efficient way?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|