Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 11th, 2003, 09:04 AM
Anitha Anitha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 8 Anitha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Converting one format of Datetime to format of date

Hi

In the database Date field is defined as Datetime For example it is stored as 2003-04-09 00:00:00 .If i want to convert that Datetime field into Date of format DD/MM/YYYY .what I should i write for this in the Select Query .

Note:
After Converting from Datetime to Date I want that Field type tobe Date Not Varchar.

Pls Help me out

From Anitha

Reply With Quote
  #2  
Old September 11th, 2003, 02:37 PM
dutch-matrix dutch-matrix is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 dutch-matrix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I think it should be somseting like this

SELECT convert(datetime, '2003-09-04', 103) FROM dummy;

103 is the format for dd/mm/yyyy i think.

(am not a t work so can not test it, will check for it tomorrow if you stil need it)

Reply With Quote
  #3  
Old September 12th, 2003, 01:01 AM
Anitha Anitha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 8 Anitha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Converting one format of Datetime to format of date

Hi

Still Not working.

Convert(datetime,'2003-03-09',103) .It is giving the result with Time for example

09/03/2003 00:00:00 .000

but i want only
09/03/2003 in date datetype not varchar type

Reply With Quote
  #4  
Old November 9th, 2004, 03:22 PM
Makito Makito is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 Makito User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
select col1, col2
From thisTable
WHERE convert (datetime, convert (varchar, datecol, 101), 101) = @yourdate

Reply With Quote
  #5  
Old May 4th, 2005, 11:21 AM
tejasvidesai tejasvidesai is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 tejasvidesai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 6 sec
Reputation Power: 0
This also returns the date with Time.
I am also facing the same problem and looking for the solution...please if someone can help?

thanks in advance,

Reply With Quote
  #6  
Old May 4th, 2005, 06:08 PM
Scorpions4ever Scorpions4ever is offline
Mad Rater
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 126 Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 31 m 44 sec
Reputation Power: 8
When you convert to a datetime, it is always going to show the time when you display the variable. This is by the definition of the datetime data-type. If you want it to only show DD/MM/YYYY, then you should convert it to varchar type.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Converting one format of Datetime to format of date


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT