Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
leo leo is offline
external usenet poster
 
Posts: 74
Default Would like an explanation of a formula:

=("1/1/"&(IF(LEFT(DQ10,4)*1<20,2000,1900)+LEFT(DQ10,4)))+ MOD(DQ10,1000)-1


The other day I needed a formula that would change a Julian date to a
calendar date, e.g., 2006031 to 01/31/06. I googled the question and found
the answer, for which I am grateful, in a formula provided by Joseph Rubins
Excel Tips. It worked like a charm and I was wondering if someone would take
the time to explain exactly how it works. Thanks

--
Leo
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 35,218
Default Would like an explanation of a formula:

First, it didn't work for me. With 2006031 in DQ10, I got 01/31/3096 as the
result.

It's trying to build a date string 1/1/someyear + SomeNumberOfDays

This portion:
(IF(LEFT(DQ10,4)*1<20,2000,1900)
is trying to determine the century of the date (19xx or 20xx). But you could
just look at the first 4 characters to find that.

Then it adds left(DQ10,4) (which is 2006) to the year.

the mod(dq10,1000) portion returns 31. The formula subtracts 1 from this, since
they started with "1/1/".

I don't think I'd use that formula. I'd use something like:

=DATE(LEFT(dq10,4),1,RIGHT(dq10,3))
And format the result as a date.

=date(year,month,day)
so this formula essentially does:
=date(2006,1,031)

If you had 2006211, the formula would be like:
=date(2006,1,211)
The 211 day of January in 2006.

Excel is pretty smart when it comes to dates. It can determine that this is
really July 30, 2006.




Leo wrote:

=("1/1/"&(IF(LEFT(DQ10,4)*1<20,2000,1900)+LEFT(DQ10,4)))+ MOD(DQ10,1000)-1

The other day I needed a formula that would change a Julian date to a
calendar date, e.g., 2006031 to 01/31/06. I googled the question and found
the answer, for which I am grateful, in a formula provided by Joseph Rubins
Excel Tips. It worked like a charm and I was wondering if someone would take
the time to explain exactly how it works. Thanks

--
Leo


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 8,651
Default Would like an explanation of a formula:

Well that formula converts 2006031 to 31 Jan 3906, rather than to 31 Jan
2006, so I wouldn't feel inclined to use it as an answer to that question.
If that works like a charm, I would want a different charm. :-)

Did you start with
=("1/1/"&(IF(LEFT(A2,2)*1<20,2000,1900)+LEFT(A2,2)))+MOD( A2,1000)-1 which
was intended to solve a slightly different problem? I believe that this
formula was intended to deal with an input of 06031, and using the
assumption that dates are between 1920 and 2019.
You can't just change the LEFT(...,2) to LEFT(...,4).

=("1/1/"&LEFT(A12,4))+MOD(A12,1000)-1 or
=("1/1/"&LEFT(A12,4))+RIGHT(A12,3)-1 would seem OK at first glance for the
question you are tring to solve.
--
David Biddulph

"Leo" wrote in message
...
=("1/1/"&(IF(LEFT(DQ10,4)*1<20,2000,1900)+LEFT(DQ10,4)))+ MOD(DQ10,1000)-1


The other day I needed a formula that would change a Julian date to a
calendar date, e.g., 2006031 to 01/31/06. I googled the question and
found
the answer, for which I am grateful, in a formula provided by Joseph
Rubins
Excel Tips. It worked like a charm and I was wondering if someone would
take
the time to explain exactly how it works. Thanks

--
Leo



  #4   Report Post  
Posted to microsoft.public.excel.newusers
leo leo is offline
external usenet poster
 
Posts: 74
Default Would like an explanation of a formula:

Thanks loads, sure makes the conversion simple, not to mention something I
can easily remember, but what does the "1" do in the middle of the formula.--
Leo


"Dave Peterson" wrote:

First, it didn't work for me. With 2006031 in DQ10, I got 01/31/3096 as the
result.

It's trying to build a date string 1/1/someyear + SomeNumberOfDays

This portion:
(IF(LEFT(DQ10,4)*1<20,2000,1900)
is trying to determine the century of the date (19xx or 20xx). But you could
just look at the first 4 characters to find that.

Then it adds left(DQ10,4) (which is 2006) to the year.

the mod(dq10,1000) portion returns 31. The formula subtracts 1 from this, since
they started with "1/1/".

I don't think I'd use that formula. I'd use something like:

=DATE(LEFT(dq10,4),1,RIGHT(dq10,3))
And format the result as a date.

=date(year,month,day)
so this formula essentially does:
=date(2006,1,031)

If you had 2006211, the formula would be like:
=date(2006,1,211)
The 211 day of January in 2006.

Excel is pretty smart when it comes to dates. It can determine that this is
really July 30, 2006.




Leo wrote:

=("1/1/"&(IF(LEFT(DQ10,4)*1<20,2000,1900)+LEFT(DQ10,4)))+ MOD(DQ10,1000)-1

The other day I needed a formula that would change a Julian date to a
calendar date, e.g., 2006031 to 01/31/06. I googled the question and found
the answer, for which I am grateful, in a formula provided by Joseph Rubins
Excel Tips. It worked like a charm and I was wondering if someone would take
the time to explain exactly how it works. Thanks

--
Leo


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 35,218
Default Would like an explanation of a formula:

=DATE(LEFT(dq10,4),1,RIGHT(dq10,3))
And format the result as a date.

=date(year,month,day)
so this formula essentially does:
=date(2006,1,031)


So the first argument is the year, the second is the month, and the third is the
day.

Leo wrote:

Thanks loads, sure makes the conversion simple, not to mention something I
can easily remember, but what does the "1" do in the middle of the formula.--
Leo

"Dave Peterson" wrote:

First, it didn't work for me. With 2006031 in DQ10, I got 01/31/3096 as the
result.

It's trying to build a date string 1/1/someyear + SomeNumberOfDays

This portion:
(IF(LEFT(DQ10,4)*1<20,2000,1900)
is trying to determine the century of the date (19xx or 20xx). But you could
just look at the first 4 characters to find that.

Then it adds left(DQ10,4) (which is 2006) to the year.

the mod(dq10,1000) portion returns 31. The formula subtracts 1 from this, since
they started with "1/1/".

I don't think I'd use that formula. I'd use something like:

=DATE(LEFT(dq10,4),1,RIGHT(dq10,3))
And format the result as a date.

=date(year,month,day)
so this formula essentially does:
=date(2006,1,031)

If you had 2006211, the formula would be like:
=date(2006,1,211)
The 211 day of January in 2006.

Excel is pretty smart when it comes to dates. It can determine that this is
really July 30, 2006.




Leo wrote:

=("1/1/"&(IF(LEFT(DQ10,4)*1<20,2000,1900)+LEFT(DQ10,4)))+ MOD(DQ10,1000)-1

The other day I needed a formula that would change a Julian date to a
calendar date, e.g., 2006031 to 01/31/06. I googled the question and found
the answer, for which I am grateful, in a formula provided by Joseph Rubins
Excel Tips. It worked like a charm and I was wondering if someone would take
the time to explain exactly how it works. Thanks

--
Leo


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to find formula & explanation on Compound Interest etc Centrol Excel Discussion (Misc queries) 1 September 26th 07 07:40 AM
FORMULA EXPLANATION SSJ New Users to Excel 7 July 26th 07 07:03 PM
Explanation of when & how to use ( ) { } : ; , ! etc? Paul (Sydney Australia) New Users to Excel 4 May 2nd 07 01:54 AM
Formula Explanation Please Ken Excel Discussion (Misc queries) 0 May 1st 07 02:23 PM


All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"