Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 13th, 2004, 11:34 AM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL datetime problem

I am storing a date in sql as a smalldatetime. When my asp application retrieves it and puts it in a datagrid it shows the date and the time. (i.e. 8/12/2004 12:00:00 AM). The time is always 12:00:00 AM since no time is given to the server. I dont want to see the time. Is there a statement i can add to the view in sql to prevent this? or some code in asp i can add?

I use enterpise manager. I think the sql version is 8 or something.

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

Hi there,

If you want to do that in SQL, try this.
Code:
select convert(varchar,DATE_COLUMN,101)
I am not sure, if you are referring to ASP/ASP.NET. I assume you are working with ASP.Net
Then you got to use this formating expression for the datagrid.
{0:MM-dd-yyyy}
OR
{0:D} as Dataformatting expression

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 16th, 2004, 02:00 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Vijay-
Formatting for datagrid works fine as told by you earlier, but with SQL SELECT command, convert function does not work. It still shows the time with the date. I have been chasing this problem since 2 weeks.

Thanks
Renu

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

Renu, I have replied you in another post. Probably you can leave out that thread and continue here on that.

Looked like you were missing a closing bracket in convert function in the other post. Did you verify that?

_________________________
- Vijay G
Strive for Perfection
 
Old August 16th, 2004, 02:16 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 statement is

select convert(char(10),workdate,101) from tbl_jurisdiction.



 
Old September 30th, 2004, 08:01 AM
Authorized User
 
Join Date: Sep 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Lalit_Pratihari
Default

Hi,

In place of char, varchar is a better option. I mean in that way you need not have to truncate the value everytime.

Thanks,

Lalit
Life Means More...;)





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql datetime type angelboy C# 2005 0 April 16th, 2007 03:02 PM
DateTime questions And SQL Data Objects ? rsearing ASP.NET 2.0 Basics 1 January 12th, 2007 04:51 PM
Sql Server DateTime field Vs ASP itHighway SQL Server ASP 2 August 16th, 2005 02:38 PM
ASP, Sql Server DateTime field itHighway Classic ASP Basics 1 August 14th, 2005 06:32 PM





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