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 |
|
parrot
Posting Yak Master
132 Posts |
Posted - 2008-06-29 : 21:44:56
|
| How can I eliminate the time portion from a date field when displaying in a GridView on a web page? For example, 10/04/2004 displays as 10-04-2004 12:00:00 AM. I want to get rid of the 12:00:00 AM suffix. The dates display properly in a Windows environment but not in a Web page. The fields are defined as smalldatetime and even using the REPLACE command will not get rid of the time suffix.Dave |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-29 : 21:57:51
|
don't convert or format it to string at the SQL side. Format to the required format in your front end web when displaying. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
parrot
Posting Yak Master
132 Posts |
Posted - 2008-06-30 : 00:20:51
|
| Thanks for everyone's help. I used the convert command as suggested , convert(char{8), 1) and got my intended result. Thank God for these forums. I really don't know how to use khtan's suggestion as I am using the OleDBDataAdapter FILL command to populate my GridView rather than using the OleDBReader command and therefore don't have access to each individual record.Dave |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-30 : 00:37:06
|
quote: Originally posted by parrot Thanks for everyone's help. I used the convert command as suggested , convert(char{8), 1) and got my intended result. Thank God for these forums. I really don't know how to use khtan's suggestion as I am using the OleDBDataAdapter FILL command to populate my GridView rather than using the OleDBReader command and therefore don't have access to each individual record.Dave
Use Format(yourdatecol,"dd/mm/yyyy") inside query you give for commandtext of OleDBDataAdapter |
 |
|
|
|
|
|