Go Back   DeveloperBarn Forums > Databases > SQL Development

Sponsored Links

Discuss "date problem" in the SQL Development forum.

SQL Development - Structured Query Language (SQL) is the talk of databases. Discuss topics such as joins, triggers and other advanced SQL topics.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old July 7th, 2008, 01:03 PM
Barn Frequenter

 
Join Date: Mar 2008
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default date problem

hi,

I have a field called dateadded field type is datetime

the values in them are like this

7/3/2008 11:26:51 AM
7/3/2008 3:42:45 AM
7/2/2008 1:57:18 PM
6/30/2008 2:37:27 AM

I want to findout distinct dates in this field

so when i display them they should be

7/3/2008
7/2/2008
6/30/2008


i have my query like this

Select Distinct(DateAdded) from employee;

Select Distinct(DateAdded) from employee ORDER BY Convert(datetime,DateAdded);

i tried these 2 queries it didnt work

can someone tell me what i am doing wrong

todd
Reply With Quote
Sponsored Links
  #2  
Old July 7th, 2008, 01:45 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

Are you using ASP? If so, just use the FormatDateTime() function to display them.

Otherwise, give us some more info such as the technology used (ASP, PHP, ASP.net) and the database (Access, MS SQL, MySQL).
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old July 7th, 2008, 01:52 PM
AOG123's Avatar
Lightning Master

 
Join Date: Mar 2008
Location: Fortress Of Solitude
Posts: 93
Thanks: 6
Thanked 23 Times in 18 Posts
Rep Power: 1
AOG123 is on a distinguished road

Awards Showcase
Microsoft Access 
Total Awards: 1

Default

Try,

select convert(varchar,DateAdded,101) from employee

For mm/dd/yy

Comments on this post
lewy agrees: That's the right way to do it
__________________
If i helped you, make me famous by clicking the
Reply With Quote
Reply

  DeveloperBarn Forums > Databases > SQL Development

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date problem todd2006 SQL Development 1 May 12th, 2008 01:51 PM


All times are GMT -4. The time now is 08:42 PM.



Content Relevant URLs by vBSEO 3.2.0