Unix Technical Forum

Re: casting smalldatetime type

This is a discussion on Re: casting smalldatetime type within the SQL Server forums, part of the Microsoft SQL Server category; --> Use this to extract date part as string: select convert(char(10), announced, 102) from mytable Check "Books Online" and look ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:15 PM
Shervin Shapourian
 
Posts: n/a
Default Re: casting smalldatetime type

Use this to extract date part as string:

select convert(char(10), announced, 102) from mytable

Check "Books Online" and look for CONVERT to get a list of differeft styles
to convert date to string.
If you need the result as SmallDateTime you can convert it again like this:

select convert(SmallDateTime, convert(char(10), announced, 102)) from
mytable

Shervin

"Richard Fox" <rfox@esops.com> wrote in message
news:3f843dab$0$14004$afc38c87@...
> I have a smalldatetime field 'announced' for which I want to do something
> like
>
> select DATE(announced) FROM mytable
>
> I am interested in only the date part (I wish there was a 'date' type

which
> did not include the time) but ms sql server does not appear to have the

DATE
> function. I haven't been able to find the equivalent in the docs... any
> suggestions? Yes, I know I can parse the value returned from the query but
> this is ugly and IMHO the server should do this heavy lifting. After all,
> little ol' MySQL does.
>
> TIA,
>
> RIch
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:52 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com