| Author |
Topic |
|
hamid.y
Starting Member
22 Posts |
Posted - 2010-03-01 : 09:03:07
|
| plz tell me how can I save only Date part of datetime datatype?as an example if the datetime is this:2010-03-07 17:18:41.473i need save 2010-03-07 and 17:18:41.473into two fields separately. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-01 : 09:06:18
|
The easy way is to get sql server 2008.The hard way is to search about it because there are tons of threads about this.But wait a moment and someone will post a "workaround"  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
hamid.y
Starting Member
22 Posts |
Posted - 2010-03-01 : 09:12:39
|
| how it possible with sql 2008?sql 2008 has separate date datatype and time datatype? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-01 : 09:14:26
|
quote: Originally posted by hamid.y how it possible with sql 2008?sql 2008 has separate date datatype and time datatype?
YesMadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-01 : 09:14:28
|
YES  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-01 : 09:15:00
|
2 seconds  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
hamid.y
Starting Member
22 Posts |
Posted - 2010-03-01 : 09:15:11
|
| thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-01 : 09:15:55
|
The smiley symbol made difference MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-01 : 09:16:45
|
quote: Originally posted by hamid.y plz tell me how can I save only Date part of datetime datatype?as an example if the datetime is this:2010-03-07 17:18:41.473i need save 2010-03-07 and 17:18:41.473into two fields separately.
in SQL 2005, the best you can do isdeclare @datetime datetimeselect @datetime = '2010-03-07 17:18:41.473'select date_only = dateadd(day, datediff(day, 0, @datetime), 0), time_only = @datetime - dateadd(day, datediff(day, 0, @datetime), 0) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|