MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

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 Dev Shed Forums Sponsor:
  #1  
Old December 18th, 2003, 04:36 AM
enviouseli enviouseli is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: South Asia
Posts: 14 enviouseli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
date time format function required

hi,

I have a celebrity table with there date of birth field. i just want to write a query which return me the celebs who's DOB is in between next 14 days.

i have wrote this query in MySQL 4.0. then i shifted my DB from MySQL to SQL server 2000.
the query in MySQL is


SELECT name,dob
FROM celeb
WHERE date_format(dob,'%c-%e') between date_format(current_date(),'%c-%e') and date_format(DATE_ADD(current_date(), INTERVAL 7 DAY),'%c-%e')

dateformat function formats the date in month and day

you can help me by just replacing this function (date_format) with any appropriate function. or u can also suggest me any alternate query with same result

thankx in advance

Reply With Quote
  #2  
Old December 18th, 2003, 10:19 AM
jstrohofer jstrohofer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Cincinnati, OH USA
Posts: 111 jstrohofer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 3 sec
Reputation Power: 10
This is the best I could come up with. Not sure if it is close or not...

SELECT name,dob
FROM celeb
WHERE CAST(CAST(MONTH(dob) AS Varchar(2)) + '/' + CAST(DAY(dob) AS Varchar(2)) + '/' + CAST(YEAR(GETDATE()) AS Varchar(4)) AS Datetime) between GETDATE() and DATE_ADD(d, 7, GETDATE())

This is assuming US date formats.

Hope that helps...

Jill

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > date time format function required

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap