Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 16th, 2004, 11:26 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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

  #2 (permalink)  
Old August 16th, 2004, 11:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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.
  #3 (permalink)  
Old August 16th, 2004, 12:04 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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".

  #4 (permalink)  
Old August 16th, 2004, 12:10 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
  #5 (permalink)  
Old August 16th, 2004, 01:01 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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.

  #6 (permalink)  
Old August 16th, 2004, 01:30 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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

  #7 (permalink)  
Old August 16th, 2004, 01:42 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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.)
  #8 (permalink)  
Old August 16th, 2004, 01:56 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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

  #9 (permalink)  
Old August 16th, 2004, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
  #10 (permalink)  
Old August 16th, 2004, 02:18 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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.


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:41 PM.


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