August 14, 2003 at 1:18 am
Hi there,
to extract the time part from a datetime field I use something like this
SELECT ...CONVERT(VARCHAR(12),MsgDateReceived,108)AS A FROM mails_header...
Is there a smarter way to do this?
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
August 14, 2003 at 1:45 am
Yes...
SELECT ...CONVERT(VARCHAR(8),MsgDateReceived,108)AS A FROM mails_header...
Cheers,
- Mark
Cheers,
- Mark
August 14, 2003 at 1:51 am
Hi Mark,
well, yes, that was indeed a typo. I was thinking of the date part
However, I was thinking if it could be easier to get the decimals of the number behind the datetime and do calculations on this. But I guess that must be pretty much the same as CONVERT( .., 108) does behind the scenes, right?
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
August 14, 2003 at 2:09 am
Hmmm, I wouldn't know what CONVERT does, but I'd guess it's more efficient than anything we could come up with using TSQL.
I'd stick with the CONVERT function. It's easily understood and has negligible overhead.
Cheers,
- Mark
Cheers,
- Mark
August 15, 2003 at 11:35 am
I wonder how long CONVERT will be around now that CAST is available. I've heard in other forums that CONVERT will eventually not be around.
Dr. Peter Venkman: Generally you don't see that kind of behavior in a major appliance.
Patrick
Quand on parle du loup, on en voit la queue
August 15, 2003 at 1:21 pm
Hi Patrick,
quote:
I wonder how long CONVERT will be around now that CAST is available. I've heard in other forums that CONVERT will eventually not be around.
good point!
I think that's more than a rumour. Somewhere I remember Microsoft giving a statement on this.
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply