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 |
djamit
Starting Member
17 Posts |
Posted - 2013-07-23 : 08:51:42
|
Hi,I have a table TIMECONTROL with a column StartTime.The column has time values in format 2013-03-09 for example.I want to convert the values of this column to a format like this 20130309.How can I solve this problem?Thank You |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-07-23 : 08:55:45
|
If the datatype is a character type then:StartTime = replace(StartTime,'-','') Too old to Rock'n'Roll too young to die. |
|
|
djamit
Starting Member
17 Posts |
Posted - 2013-07-23 : 09:09:54
|
Can you write down the whole code please |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-07-23 : 09:22:14
|
update TIMECONTROLset StartTime = replace(StartTime,'-','') Too old to Rock'n'Roll too young to die. |
|
|
djamit
Starting Member
17 Posts |
Posted - 2013-07-23 : 10:52:45
|
Thank you very much |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-07-23 : 12:36:01
|
Which DATATYPE is the StartTime column? If it's DATETIME/SMALLDATETIME/DATE/DATETIME2/DATETIMEOFFSET, everything is OK. Then you are using dates correctly and the hyphen is just a presentation issue; nothing to worry about.However, if the StartTime column is VARCHAR/CHAR/NVARCHAR/NCHAR datatype, then you will have tons of problems in the future. Please consider using a proper datatype fpr handling dates. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-24 : 01:55:18
|
Why cant you do this at your front end application as its just a presentation issue?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|