tag:blogger.com,1999:blog-5655811.post114013507015209262..comments2024-03-14T02:32:59.473-07:00Comments on Greg's Cool [Insert Clever Name] of the Day: Get Only Date from DateTime in T-SQLGreghttp://www.blogger.com/profile/00904998050540497754noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-5655811.post-64594735610658029982012-08-09T17:48:10.711-07:002012-08-09T17:48:10.711-07:00Hi try this..http://codingresolved.com/discussion/...Hi try this..<a href="http://codingresolved.com/discussion/62/how-to-get-date-from-datetime-in-sql#Item_2" rel="nofollow">http://codingresolved.com/discussion/62/how-to-get-date-from-datetime-in-sql#Item_2</a>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-75554967683203747932012-08-07T08:53:40.189-07:002012-08-07T08:53:40.189-07:00Thank you! its a very simple solution. I will make...Thank you! its a very simple solution. I will make it a scalar function under the database and can reuse it in the future.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-85316072653526441092012-04-13T09:24:31.570-07:002012-04-13T09:24:31.570-07:00Convert(Date, Getdate())
in SQL SERVER 2008, Inst...Convert(Date, Getdate())<br /><br />in SQL SERVER 2008, Instead Of Using CASTAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-24011897072449806252011-04-18T06:06:03.548-07:002011-04-18T06:06:03.548-07:00I use a quite easy solution:
CAST(GETDATE() as DAT...I use a quite easy solution:<br />CAST(GETDATE() as DATE)Matej Kovacnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-82776908149477976502011-04-05T02:48:34.564-07:002011-04-05T02:48:34.564-07:00cast(cast(getdate() as int) as datetime)cast(cast(getdate() as int) as datetime)ángel bloggerhttps://www.blogger.com/profile/00889537630247360584noreply@blogger.comtag:blogger.com,1999:blog-5655811.post-23710983482349475232010-01-19T13:18:01.444-08:002010-01-19T13:18:01.444-08:00CONVERT(DATETIME, FLOOR(CONVERT(INT,GETDATE())))CONVERT(DATETIME, FLOOR(CONVERT(INT,GETDATE())))Unknownhttps://www.blogger.com/profile/18282812864008339858noreply@blogger.comtag:blogger.com,1999:blog-5655811.post-64024787983007222682010-01-13T14:57:52.476-08:002010-01-13T14:57:52.476-08:00CONVERT(VARCHAR,start_dttm,111)
Converts
'20...CONVERT(VARCHAR,start_dttm,111)<br /><br />Converts<br /><br />'2009/12/01 11:56:34'<br />or<br />'12/01/2009 11:56:34'<br /><br />into this<br />'2009-12-01'SidCharminghttps://www.blogger.com/profile/01403684558687490349noreply@blogger.comtag:blogger.com,1999:blog-5655811.post-68953179112964041192008-12-11T06:15:00.000-08:002008-12-11T06:15:00.000-08:00I usually write like this:select convert(varchar(1...I usually write like this:<BR/>select convert(varchar(10),getdate(),121)<BR/><BR/>Then you only get the date like:<BR/>2008-12-11<BR/><BR/>/TobiasAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-65832021034544781652008-05-29T00:30:00.000-07:002008-05-29T00:30:00.000-07:00Converting a date to an int, then back to a data w...Converting a date to an int, then back to a data will result in a whole date (time being dropped), but is not reliable. The reason is that rounding occurs and if the time portion is more than .5 of a day the date you get is for the following day. <BR/><BR/>Try THis:<BR/>cast(cast(Getdate() as char(11)) as datetime)<BR/>-RichardAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5655811.post-1140186289402422712006-02-17T06:24:00.000-08:002006-02-17T06:24:00.000-08:00Here's another way to do it, which is almost certa...Here's another way to do it, which is almost certainly less portable:<BR/><BR/>select cast(cast(getdate() as int ) as datetime)<BR/><BR/>It depends on the fact that, internally, dates are stored as the ole date format, a fractional number of days past some epoch start.JPhttps://www.blogger.com/profile/14985302852355510033noreply@blogger.com