Wrox Programmer Forums
|
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
 
Old August 16th, 2004, 11:26 AM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old August 16th, 2004, 11:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old August 16th, 2004, 12:04 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for such a quick response. I am using a textbox. Should any other control be used? The format needed is "mm-dd-yyyy".

 
Old August 16th, 2004, 12:10 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Take a look at DateTime formatting:

http://msdn.microsoft.com/library/de...matstrings.asp
 
Old August 16th, 2004, 01:01 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old August 16th, 2004, 01:30 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old August 16th, 2004, 01:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.)
 
Old August 16th, 2004, 01:56 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old August 16th, 2004, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old August 16th, 2004, 02:18 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Time getting displayed along with Date mahulda Classic ASP Databases 15 August 16th, 2004 02:05 PM
Date and Time Displayed Together in DataGrid mahulda Classic ASP Databases 4 July 17th, 2004 11:03 PM
Date and Time Displayed Together in DataGrid mahulda ADO.NET 2 July 16th, 2004 04:43 AM
Not getting "time" displayed in the first example dotnetabhi VS.NET 2002/2003 6 March 27th, 2004 11:53 AM
time displayed damnnono_86 Access 2 November 28th, 2003 01:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.