| Author |
Topic |
|
h7y
Starting Member
4 Posts |
Posted - 2005-11-09 : 01:39:41
|
| I'm new here, so not sure if this is the correct forum.I've been trying at this for the past 5 hours, if anyone could help. I would be GREATLY appreciated.I have a field that stores date, the datatype is smalldatetime that i'm using. The default is (getdate()) . The problem is this, i want date only like 11/9/2005 but it keeps doing 11/9/2005 9:45:26 PM.Is there any way i can tell it to only input the date. I was also reading somewhere that i could use something like this... (getdate()(Left,yourtime,8)) but that didn't seem to work.Please help!Thanks!i need help |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-09 : 01:48:05
|
| Somthing like this Select Convert(Varchar(10),GetDAte(),101)Or look out for the Convert on Book online.. for more detailsComplicated things can be done by simple thinking |
 |
|
|
h7y
Starting Member
4 Posts |
Posted - 2005-11-09 : 01:51:23
|
| Thank you for the reply... i'm really new to this, so forgive me if this is one of those dumb questions.I put that into the default part right? I used what you putand replaced (getdate()) with that. When i saved I got this error....- Error modifying column properties for 'DateEntered'. ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'Select'.[Microsoft][ODBC SQL Server Driver][SQL Server]Line 2: Incorrect syntax near 'DateEntered'.What did I do wrong?i need help |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-09 : 01:57:18
|
| Can you post the query what you tried?? and also same sample data about the output what you want???Complicated things can be done by simple thinking |
 |
|
|
h7y
Starting Member
4 Posts |
Posted - 2005-11-09 : 02:06:36
|
| Sure,Actually my friend just told me to try something else. I did and something strange happened.The datatype is still smalldatetime but for the default i used(left(getdate(),8))Which now it gives the correct date format .. i,e, mm/dd/yyyy but forsome strange reason it keeps thinking its 2002 , i've tried changing the number to 10 as well.Do you know why it would just pick 2002?i need help |
 |
|
|
h7y
Starting Member
4 Posts |
Posted - 2005-11-09 : 02:19:56
|
| sharaq, you are my new best friend. THANK YOU THANK YOU.I used Convert(Varchar(10),GetDAte(),101) that you told me for default.It works now!THANKS!i need help |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-09 : 02:20:58
|
| oks.. well. to covert the datetime or to remove the time part from the date... Convert function is the best way to do so.. Why are you trying to use left.. ??? Can you post the same data .. means the what data is there in your table and what is the expected result that you would like to get ??Complicated things can be done by simple thinking |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-09 : 02:23:09
|
| Where do you want to show this converted date?MadhivananFailing to plan is Planning to fail |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-09 : 02:23:49
|
quote: Originally posted by h7y sharaq, you are my new best friend. THANK YOU THANK YOU.I used Convert(Varchar(10),GetDAte(),101) that you told me for default.It works now!THANKS!i need help
Well great to know that it worked for you.. ..Complicated things can be done by simple thinking |
 |
|
|
|