PC Review


Reply
Thread Tools Rate Thread

Day of year (Not Julian)

 
 
Rick S.
Guest
Posts: n/a
 
      18th Apr 2008
I am using this formula from Chip Pearson's web site.
'======
=RIGHT(YEAR(A1),2)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
'======
Which will take a date "04/18/08" and display it as "08109".
"08" is the year while "109" is the day of the year.

1. I need to strip the leading zero's
2. How can I make a column convert a date to this format when ever a date is
entered?

--
Regards

XP Pro
Office 2007

 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      18th Apr 2008
Stripping the leading zero:

=VALUE(RIGHT(YEAR(A1),2))&TEXT(A1-DATE(YEAR(A1),1,0),"000")

I don't understand #2.

--
Jim
"Rick S." <(E-Mail Removed)> wrote in message
news:F193FA33-38D7-4098-8362-(E-Mail Removed)...
|I am using this formula from Chip Pearson's web site.
| '======
| =RIGHT(YEAR(A1),2)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
| '======
| Which will take a date "04/18/08" and display it as "08109".
| "08" is the year while "109" is the day of the year.
|
| 1. I need to strip the leading zero's
| 2. How can I make a column convert a date to this format when ever a date
is
| entered?
|
| --
| Regards
|
| XP Pro
| Office 2007
|


 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      18th Apr 2008
To remove the leading zero:

=RIGHT(YEAR(A1),1)&TEXT(A1-DATE(YEAR(A1),1,0),"000")

this will work for all years from 2001 thru 2009.


If you are entering normal dates in column A and want them to be converted
automatically, then include the following event code in the worksheet code
area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A:A")
If Intersect(Target, r) Is Nothing Then Exit Sub
Dim d As Date
d = Target.Value
t = Chr(34) & d & Chr(34)
s1 = "=RIGHT(YEAR("
s2 = "),1)&TEXT("
s3 = "-DATE(YEAR("
s4 = "),1,0),""000"")"
s = s1 & t & s2 & t & s3 & t & s4
k = Evaluate(s)
Application.EnableEvents = False
Target.NumberFormat = "@"
Target.Value = k
Application.EnableEvents = True
End Sub



Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200780


"Rick S." wrote:

> I am using this formula from Chip Pearson's web site.
> '======
> =RIGHT(YEAR(A1),2)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
> '======
> Which will take a date "04/18/08" and display it as "08109".
> "08" is the year while "109" is the day of the year.
>
> 1. I need to strip the leading zero's
> 2. How can I make a column convert a date to this format when ever a date is
> entered?
>
> --
> Regards
>
> XP Pro
> Office 2007
>

 
Reply With Quote
 
Rick S.
Guest
Posts: n/a
 
      21st Apr 2008
Formula works great!
--
Regards

XP Pro
Office 2007



"Jim Rech" wrote:

> Stripping the leading zero:
>
> =VALUE(RIGHT(YEAR(A1),2))&TEXT(A1-DATE(YEAR(A1),1,0),"000")
>
> I don't understand #2.
>
> --
> Jim
> "Rick S." <(E-Mail Removed)> wrote in message
> news:F193FA33-38D7-4098-8362-(E-Mail Removed)...
> |I am using this formula from Chip Pearson's web site.
> | '======
> | =RIGHT(YEAR(A1),2)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
> | '======
> | Which will take a date "04/18/08" and display it as "08109".
> | "08" is the year while "109" is the day of the year.
> |
> | 1. I need to strip the leading zero's
> | 2. How can I make a column convert a date to this format when ever a date
> is
> | entered?
> |
> | --
> | Regards
> |
> | XP Pro
> | Office 2007
> |
>
>
>

 
Reply With Quote
 
Rick S.
Guest
Posts: n/a
 
      21st Apr 2008
Gary, Thanks!
This is where I was stuck, simply did not see how to or should have disected
everything and then put it back together.

--
Regards

XP Pro
Office 2007



"Gary''s Student" wrote:

> To remove the leading zero:
>
> =RIGHT(YEAR(A1),1)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
>
> this will work for all years from 2001 thru 2009.
>
>
> If you are entering normal dates in column A and want them to be converted
> automatically, then include the following event code in the worksheet code
> area:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Set r = Range("A:A")
> If Intersect(Target, r) Is Nothing Then Exit Sub
> Dim d As Date
> d = Target.Value
> t = Chr(34) & d & Chr(34)
> s1 = "=RIGHT(YEAR("
> s2 = "),1)&TEXT("
> s3 = "-DATE(YEAR("
> s4 = "),1,0),""000"")"
> s = s1 & t & s2 & t & s3 & t & s4
> k = Evaluate(s)
> Application.EnableEvents = False
> Target.NumberFormat = "@"
> Target.Value = k
> Application.EnableEvents = True
> End Sub
>
>
>
> Because it is worksheet code, it is very easy to install and automatic to use:
>
> 1. right-click the tab name near the bottom of the Excel window
> 2. select View Code - this brings up a VBE window
> 3. paste the stuff in and close the VBE window
>
> If you have any concerns, first try it on a trial worksheet.
>
> If you save the workbook, the macro will be saved with it.
>
>
> To remove the macro:
>
> 1. bring up the VBE windows as above
> 2. clear the code out
> 3. close the VBE window
>
> To learn more about macros in general, see:
>
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> To learn more about Event Macros (worksheet code), see:
>
> http://www.mvps.org/dmcritchie/excel/event.htm
>
> --
> Gary''s Student - gsnu200780
>
>
> "Rick S." wrote:
>
> > I am using this formula from Chip Pearson's web site.
> > '======
> > =RIGHT(YEAR(A1),2)&TEXT(A1-DATE(YEAR(A1),1,0),"000")
> > '======
> > Which will take a date "04/18/08" and display it as "08109".
> > "08" is the year while "109" is the day of the year.
> >
> > 1. I need to strip the leading zero's
> > 2. How can I make a column convert a date to this format when ever a date is
> > entered?
> >
> > --
> > Regards
> >
> > XP Pro
> > Office 2007
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert from julian date to mm/dd/year =?Utf-8?B?cm9iaW4gd2F0ZXJzb25n?= Microsoft Excel Misc 6 9th Sep 2007 04:18 AM
Print the day of the year (or Julian date) on an Outlook calendar? =?Utf-8?B?TC4gQS4gVy4=?= Microsoft Outlook Calendar 1 2nd Mar 2007 12:06 AM
Pulling a date from a two digit year and julian date Ziggs Microsoft Access 3 25th Dec 2006 07:59 PM
converting julian day and year to a date? =?Utf-8?B?Q2hhZCBOb3JkYmVyZw==?= Microsoft Excel Worksheet Functions 1 27th Feb 2006 10:23 PM
Excel should support DAYOFYEAR(year,month,day) returns julian dat. =?Utf-8?B?TmVpbA==?= Microsoft Excel Worksheet Functions 1 24th Feb 2005 04:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:04 AM.