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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date Query

Author  Topic 

ayu
Starting Member

43 Posts

Posted - 2009-01-14 : 11:46:28
hi guys,

if u'll execute this query -
SELECT CONVERT(VARCHAR(8), getdate(), 1) - will get
01/14/09

i want same DD/MM/YY format for this given date -
'Wed, 19 Oct 2005 18:04:36 -040' instead of getdate()

if i will use
select CONVERT(VARCHAR, 'Wed, 19 Oct 2005 18:04:36 -040', 1) - will get Wed, 19 pbviously...but can anyone tell me how can i get in MM/DD/YY format? as there are 890 values in date columns and i have to
convert all values in DD/MM/YY format.

thanks for ur help..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 11:51:14
this is a presentation issue and has to dealt with in your front end application using formatting functions.
Go to Top of Page

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-01-14 : 12:17:14
If it helps at all, SELECT CONVERT(VARCHAR(25),GETDATE(),101) will get you 1/14/2009 format. To format to the 2-digit year you'll have to play with the varchar string some more. However like visakh said, your formatting should be done on the presentation layer rather than in the database.
Go to Top of Page

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-01-14 : 12:22:38
This will actually do it:
SELECT REPLACE(CONVERT(VARCHAR(25),GETDATE(),10),'-','/')
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 12:22:53
also how come you've Wed, 19 Oct 2005 18:04:36 -040 as datevalue in your table? that clearly suggests you're not using datetime datatype for field. Always try to use proper datatypes for your fields. ELse you're really making manipulations complicated
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-15 : 23:49:58
check these links for date formats
www.sql-server-helper.com/tips/date-formats.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563
Go to Top of Page
   

- Advertisement -