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.
| Author |
Topic |
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-09-14 : 14:37:43
|
| How to convert the current date (getdate()) to a georgian date. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-14 : 14:38:21
|
| What does the Georgian date format look like?Tara |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-09-14 : 15:05:04
|
| It count of days 1-365. |
 |
|
|
Vivaldi
Constraint Violating Yak Guru
298 Posts |
Posted - 2005-09-14 : 15:10:45
|
quote: Originally posted by sardinka It count of days 1-365.
just guessing, but do you mean (Days in Year) - (Day Number in year)DateDiff in days from the beginning or end of the year should work.my limited education hasn't familiarized my brain with such a format.________________________________________________Working man's privilege, beer is.Harsh, Life is. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-14 : 15:10:54
|
| I don't understand what you mean. Could you provide an example?Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-09-14 : 15:18:56
|
| [code]USE NorthwindGOCREATE FUNCTION udf_Julian ( @d datetime)RETURNS varchar(7) BEGIN RETURN (SELECT CONVERT(char(4),YEAR(@d))+CONVERT(varchar(3),DATEPART(dy,@d))) ENDSELECT GetDate(), dbo.udf_Julian(GetDate())GODROP FUNCTION udf_JulianGO[/code]Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2005-09-14 : 15:25:06
|
| Thank you for your function that is exactly what I want. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-09-14 : 16:14:56
|
| Are you sure that's right? What should January 1, 2005 return? (I am not 100% positive, but I would think 2005001 and not 20051 but I could be wrong).declare @d datetimeset @d= '1/1/2005'-- What Brett has:SELECT CONVERT(char(4),YEAR(@d))+CONVERT(varchar(3),DATEPART(dy,@d))-- But what about something like:select Year(@d) * 1000 + DatePart(dy,@d) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-09-15 : 02:24:10
|
| OrRETURN (SELECT CONVERT(char(4),YEAR(@d))+RIGHT('000', CONVERT(varchar(3),DATEPART(dy,@d)), 3))is you want a string rather than a numeric valueKristen |
 |
|
|
|
|
|
|
|