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 |
|
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'sthe 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 datedateadd(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. KHChoice 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 |
 |
|
|
Pat Phelan
Posting Yak Master
187 Posts |
Posted - 2006-03-30 : 22:13:03
|
| [code]DECLARE @d DATETIMESELECT @d = '2006-03-30'SELECT 1000 * (Year(@d) - 1900) + DatePart(dy, @d)[/code]-PatP |
 |
|
|
misterzr
Starting Member
49 Posts |
Posted - 2006-03-31 : 09:52:04
|
| Thanks Pat, this works great |
 |
|
|
|
|
|
|
|