 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 16th, 2004, 11:26 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Time displayed with date! Please help
I am using SQL server and running a sql SELECT query. The date column is displaying date and time. I need to get rid of the time part. I have tried convert function, casting etc.. but none seems to work. Any help on this will be greatly appreciated.
Thanks.
Renu
|
|

August 16th, 2004, 11:58 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
In what type of control are you displaying the datetime? You can use String.Format or some formatting string in most controls to specify what format of the date you would like.
|
|

August 16th, 2004, 12:04 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for such a quick response. I am using a textbox. Should any other control be used? The format needed is "mm-dd-yyyy".
|
|

August 16th, 2004, 12:10 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
|
|

August 16th, 2004, 01:01 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I believe the link you sent can be used to write a function and get the date in the required format. I am sure there must be a function that can directly be used in the SELECT command.
|
|

August 16th, 2004, 01:30 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is very strange. I ran the following statement in the query analyser on sql server and it ran fine... If gives me the date in the format I want.
select convert(char(10,workdate,101) from tbl_jurisdiction
But, when I use the same convert function in the select command generated by VS.NET, I get blank date!! Any comments on this will be highly appreciated.
Thanks in advance.
Renu
|
|

August 16th, 2004, 01:42 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
this is probably because you are trying to extract a specific field in your .NET code. when you do that function in SQL, you have to re-assign the fieldname as the alias of the output so that .NET can get at the value:
select convert(char(10,workdate,101) AS workdate from tbl_jurisdiction
(By the way, there are several SQL language forums on here that might yield you better results for SQL specific questions.)
|
|

August 16th, 2004, 01:56 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tried with ....AS workdate....
but still it doesn't work. I am going to check in SQL forum as suggested by you. In the meanwhile, if anybody knows answer to this question, please post it here. Thanks
Renu
|
|

August 16th, 2004, 02:00 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Renu,
There seems to be bracket missing in your code. Was that really missing?
Code:
select convert(char(10),workdate,101) as WorkDate from tbl_jurisdiction
Can you check, if that helps?
_________________________
- Vijay G
Strive for Perfection
|
|

August 16th, 2004, 02:18 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ya, that was just a typo. The bracket was there.
Let's resume it here at this thread. I just went to SQL forum hoping that I would get some answer.
|
|
 |