Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Getdate() Format

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2011-09-15 : 05:30:30
Hi All,

I want to generate getdate() as following format 15-Sep-2011
can u guys pls help me ASAP

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-15 : 05:49:38
try to do it at front end as its a presentation issue.or else make use of CONVERT

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2011-09-15 : 05:49:45
Just try this one.

SELECT convert(varchar,getdate(),13)
Go to Top of Page

aoriju
Posting Yak Master

156 Posts

Posted - 2011-09-15 : 06:02:05
Villanuev
This "SELECT convert(varchar,getdate(),13)" not staisfied my requirement
I got it through this way,
SELECT REPLACE(CONVERT(VARCHAR(11), GETDATE(),106),' ','-') AS DateFormat
Anyway thanks for your reply
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-15 : 07:41:03
quote:
Originally posted by aoriju

Villanuev
This "SELECT convert(varchar,getdate(),13)" not staisfied my requirement
I got it through this way,
SELECT REPLACE(CONVERT(VARCHAR(11), GETDATE(),106),' ','-') AS DateFormat
Anyway thanks for your reply


keep in mind that you're making date manipulations difficult for you by changing its native data type. All this just for display format sake, which can be very easily achieved in any front end programming language using format functions.
So unless there was no other way out, what you're doing here is not a recommended approach

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -