Re: Only get dates
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/27/04
- Next message: John Steen: "RE: Help Finding records with matching columns"
- Previous message: Gary K: "Only get dates"
- In reply to: Gary K: "Only get dates"
- Next in thread: Gary K: "Re: Only get dates"
- Reply: Gary K: "Re: Only get dates"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Aug 2004 08:56:10 +0200
On Thu, 26 Aug 2004 22:19:04 -0700, Gary K wrote:
>Can anyone help me create an expression for a column in a query that holds
>only the date portion of a smalldatetime column? I've tried DatePart and had
>a look around for other functions but I couldn't find anything. Thanks in
>advance,
Hi Gary,
Use CONVERT to convert it to character, using a format without time (or
using a character column short enough that the time won't fit). If you
need it in datetime format without the time (you'll get the default time:
midnight), cast the result back to datetime format.
SELECT getdate()
SELECT CONVERT (varchar(8), GETDATE(), 112)
SELECT CAST(CONVERT (varchar(8), GETDATE(), 112) AS datetime)
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: John Steen: "RE: Help Finding records with matching columns"
- Previous message: Gary K: "Only get dates"
- In reply to: Gary K: "Only get dates"
- Next in thread: Gary K: "Re: Only get dates"
- Reply: Gary K: "Re: Only get dates"
- Messages sorted by: [ date ] [ thread ]