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 2000 Forums
 SQL Server Development (2000)
 Convert date format 2004-08-31 to 08/31/2004

Author  Topic 

nickmollberg
Starting Member

3 Posts

Posted - 2005-08-29 : 10:24:45
Anyone know the syntax for reformatting a date column like this?
I need to convert date format 2004-08-31 to 08/31/2004 or, even better...
How can I convert 2004-08-31 into a JULIAN date format?
i.e.

Julian Regular
693596 = 1/1/1900

732155 = 7/28/2005

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 10:30:49
You can handle this type of Date formations in the Front End application or Reports
Otherwise use convert function

Declare @t datetime
Set @t='2004-08-31'
Select Convert(varchar,@t,101)

What is the logic used in the Julian Dates?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2005-08-29 : 16:08:52
You should look up "convert" in books online..."101" in the select statement from madhivanan refers to a constant that can be found by looking in BOL for "convert".

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

nadejda18
Starting Member

7 Posts

Posted - 2005-08-29 : 17:28:12
If you mean julian format is a number of the days from the beginning of year, you can use DATEDIFF function:

DATEDIFF ( dd , "01/01/2005", "your date" )
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-08-30 : 09:32:46
*takes out bat*
[ beat dead horse]
FORMATING is handled on the CLIENT.
[ /beat dead horse]

Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page
   

- Advertisement -