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 September 25th, 2003, 07:28 AM
buggirl buggirl is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sweden
Posts: 6 buggirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
date function

How do I change this function so that it shows dates like this 2003-05-03 and not 2003-5-3?
And I also want to add a parameter so that the user can choose if it should show :
2003-03-03 or 03-03-03

create function ShowDate(@indate datetime, @separator char(1))
returns nchar(20)
as
begin
return
convert(nvarchar(20), datepart(yyyy, @indate))
+ @separator
+ convert(nvarchar(20), datepart(mm, @indate))
+ @separator
+ convert(nvarchar(20), datepart(dd, @indate))
end

Reply With Quote
  #2  
Old September 29th, 2003, 11:15 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 11
this will get your date the way you want it, except it uses . instead of - as a seperator. what programming language are you using to display this data?

select convert(varchar(20),date_field,102) as 'date' from table_name
__________________
My brain cells are like a storm trooper's armor: useless

Reply With Quote
  #3  
Old September 29th, 2003, 11:53 AM
buggirl buggirl is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sweden
Posts: 6 buggirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I solved my problem by sitting up all night, but thanks for your input!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > date function

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