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 |
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-02-20 : 22:13:37
|
Good day!DateTimeIn-------------------2/19/2003 8:00:00 AM2/20/2003 8:00:00 AM2/21/2003 8:00:00 AMI want to separate the date and time...result should look exactly like this...DateIn TimeIn -------------------2/19/2003 8:00:00 AM2/20/2003 8:00:00 AM2/21/2003 8:00:00 AM Want Philippines to become 1st World COuntry? Go for World War 3... |
|
|
Ex
Posting Yak Master
166 Posts |
Posted - 2005-02-20 : 22:21:55
|
| could use substring.. assumping @dateIn is the inputDECLARE @dateOut varchar(2)select @dateOut = SUBSTRING(@dateIn,1,1) + '/' + SUBSTRING(@dateIn,3,2) + '/' + SUBSTRING(@dateIn,6,4) +'/' + SUBSTRING(@dateIn,6,4)that woud give you the dateand do somethig similar for the time |
 |
|
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-02-20 : 22:34:22
|
| Ooooooppppsss... i forgot.How about not using a substring coz i already new that. Is there other way? if possible the shortest and simple way.tnx.Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-02-21 : 04:15:17
|
if DateTimeIn is datetime then:select convert(varchar(10), DateTimeIn, 101), convert(varchar(15), DateTimeIn, 108)if it's a varchar then use substring or left() and right() functions.Go with the flow & have fun! Else fight the flow |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-02-21 : 10:09:23
|
| Most applications used to present data that has been retrieved from Sql Server are much better at formatting values. Are the your users of this data simply executing your query/SP or can you let your presentation software handle the formatting?Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|