Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-01-11 : 11:07:40
|
| How do I extract the ate and time from a datetime field. The field is called Log_DateTime. I want to extract the date and the time and then use these two expressions to sort/filter on in Query Analyzer. |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-01-11 : 11:15:24
|
| CONVERT (nvarchar, Log_DateTime, 101)CONVERT (nvarchar, Log_DateTime, 108) |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-11 : 11:18:34
|
| why nvarchar?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-01-12 : 10:41:57
|
| Don't know - I found the code on the web - it works. What should I use instead ? |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-12 : 11:06:15
|
| nvarchar will take double the space than varchar. If you don't have any special requirement to store UNICODE characters, you can use VARCHAR as well.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-01-12 : 11:39:45
|
| Finding the Start of Time PeriodsOne of the most common questions is how to remove the time from a datetime so that you end up with just a date. In other words, change 2006/12/13 02:33:48.347 to 2006/12/13 00:00:00.000. The following links have functions that will find the start of Century, Decade, Year, Quarter, Month, Week, Day, Hour, 30 Minutes, 20 Minutes, 15 Minutes, 10 Minutes , 5 Minutes , x number of Minutes ,Minute , or Second.Start of Time Period Functions:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755Getting Time Only from DateTimeBy convention, a time only column is stored in SQL Server as an offset from 1900-01-01 00:00:00.000. The function on this link will get the time from a datetime value.Time Only Function: F_TIME_FROM_DATETIMEhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65358Date/Time Info and Script Linkshttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762CODO ERGO SUM |
 |
|
|
|
|
|
|
|