June 10, 2008 at 5:11 am
Hi,
Good afternoon
I want to display date date format like dd-MMM-YYYY
eg:-
My Requirement like this...
from Date is 27th April 2008 then i want diplay this from Dat like this format 27-Apr-2008
i tried like this
SELECT CONVERT( CHAR(6), fromDate, 106 )
FROM EMP
it gives out put like this :- 27 Apr 08
but i want out format like this 27-Apr - 2008
Plz hekp me to achive this
Regds,
Rclgoriparthi
June 10, 2008 at 5:36 am
select datepart(dd,columnname) +'-'+datepart(mm,columnname) +'-'+datepart(yy,columnname)
Check it out.
karthik
June 10, 2008 at 5:48 am
rclgoriparthi (6/10/2008)
it gives out put like this :- 27 Apr 08
but i want out format like this 27-Apr - 2008
Use function REPLACE on the result you've got.
_____________
Code for TallyGenerator
June 10, 2008 at 7:10 am
Once you have the month, you might need to use the Monthname function to get the full name. Look up date functions in Books Online.
June 26, 2008 at 4:20 pm
looks like you result convert isnt big enough to start with char(6) wont hold dd_-_mmm_-_yyyy
the format of type 6 give the two diget year you displayed and 106 gives the four digit year required
as Sergiy suggested use the replace function is most probably the best optioni
My suggested fragment would be
replace(convert(char(15),fromdate,106),' ',' - ')
what it does is get the date in format 106 = dd_mmm_yyyy (where _ is a space)
replace then replaces spaces with a space + your hyphen + space
Hope that is a solution for you.
June 27, 2008 at 11:15 am
yet another way 'to skin' the SQL cat:
select replace(convert(char(11),getdate(),113),' ','-')
😉
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply