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 |
|
jasonsy
Starting Member
11 Posts |
Posted - 2010-03-11 : 00:38:31
|
| How can i change my column that is a date format with for example2010-01-08 00:00:00.000thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2010-03-11 : 00:39:37
|
| If your column is datetime data type, then you can not change the format that it gets saved as. You can change the format when you retrieve it out of the database using the CONVERT function and the appropriate style, but it's better to do the formatting in your application rather than T-SQL since it's a presentation layer issue.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong." |
 |
|
|
jasonsy
Starting Member
11 Posts |
Posted - 2010-03-11 : 00:48:30
|
| I really need this value for my date because my program will not run if that's not the value. My column is null. is it possible to have a datetime format with this value 2010-01-08 00:00:00.000?thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-11 : 02:17:31
|
quote: Originally posted by jasonsy I really need this value for my date because my program will not run if that's not the value. My column is null. is it possible to have a datetime format with this value 2010-01-08 00:00:00.000?thanks
What is the datatype of the date column?If the column is NULL, is there a reason to update it with 2010-01-08 00:00:00.000?MadhivananFailing to plan is Planning to fail |
 |
|
|
jasonsy
Starting Member
11 Posts |
Posted - 2010-03-11 : 02:23:43
|
| datetime. yup the date should be the current date but the time it must be 00:00:00.000. is it possible? |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-11 : 02:28:05
|
| use thisselect dateadd(d,datediff(d,0,getdate()),0) |
 |
|
|
jasonsy
Starting Member
11 Posts |
Posted - 2010-03-11 : 02:35:24
|
| many thanks! |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-11 : 05:27:44
|
quote: Originally posted by jasonsy many thanks!
Welcome... |
 |
|
|
|
|
|