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)
 Date command help

Author  Topic 

misterzr
Starting Member

49 Posts

Posted - 2006-03-30 : 17:08:31
I am working with a JDEdwards database and it stores the date in an almost Julian date format such as 106089 that equals todays date(Mar 30/06) The first digit is a century marker, 0 for 1900's,1 for 2000's
the second and third digit is the year, the last 3 are the day of the year with a lead zero if needed.

My question is how can I create a select in SQL that will display this by todays date(or plus or minus days from today)

I have come up with this to change back from this date to a normal looking date
dateadd(day,cast(sdivd as int)%1000-1,dateadd(year,sdivd/1000,'1/1/1900'))

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-30 : 20:28:19
"My question is how can I create a select in SQL that will display this by todays date(or plus or minus days from today)"
Not very sure what do you need. But you can use datediff() to find out the different between 2 dates. And use getdate() to obtain current date & time.



KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page

Pat Phelan
Posting Yak Master

187 Posts

Posted - 2006-03-30 : 22:13:03
[code]DECLARE @d DATETIME
SELECT @d = '2006-03-30'

SELECT 1000 * (Year(@d) - 1900) + DatePart(dy, @d)[/code]-PatP
Go to Top of Page

misterzr
Starting Member

49 Posts

Posted - 2006-03-31 : 09:52:04
Thanks Pat, this works great
Go to Top of Page
   

- Advertisement -