Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-24-2008, 09:55 PM
Lars
 
Posts: n/a
Compare Now() to a European date

This is driving me nuts,

I have a list of certificates. In column B their expiry dates are
entered as Europeans, some at least, do. Like today would be 20080524.

I want these cells to change colour with conditional formating.
For instance becoming yellow when there is less than three months
between now and the expiry date, and then becoming red when there
is less than one month to expiry. Else they should remain without
colour.

I have read through a hundred posts dealing with similar needs and
seemingly fine replies, but I get nowhere with my particular sheet.

When I format my B cell as "custom" yyyymmdd and enter my date
Excel says that negative dates are displayed as ##########.
When I leave its format as "general" the cells become red whatever
number I enter there.

I have tried having a now-function in a separate cell and comparing my
B's to it, but it does not even give a clue to where I am doing wrong.

Any ideas?


Lars
Stockholm
Reply With Quote
  #2 (permalink)  
Old 05-25-2008, 12:25 AM
Bernard Liengme
 
Posts: n/a
Re: Compare Now() to a European date

In Excel dates are stores as numbers starting from 1/1/1900
Only formatting changes what the show as on the worksheet
Sounds like you 20080524 is either text or just a number but not an Excel
date
If the entry 20000524 is text or number then
=DATE(--LEFT(A1,4),--MID(A1,5,2),--RIGHT(A1,2))
will give you a real date
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Lars" <Lars@fake.com> wrote in message
news:3cvg34p0ickrk11drjb61lcd6s7s27k9cd@4ax.com...
> This is driving me nuts,
>
> I have a list of certificates. In column B their expiry dates are
> entered as Europeans, some at least, do. Like today would be 20080524.
>
> I want these cells to change colour with conditional formating.
> For instance becoming yellow when there is less than three months
> between now and the expiry date, and then becoming red when there
> is less than one month to expiry. Else they should remain without
> colour.
>
> I have read through a hundred posts dealing with similar needs and
> seemingly fine replies, but I get nowhere with my particular sheet.
>
> When I format my B cell as "custom" yyyymmdd and enter my date
> Excel says that negative dates are displayed as ##########.
> When I leave its format as "general" the cells become red whatever
> number I enter there.
>
> I have tried having a now-function in a separate cell and comparing my
> B's to it, but it does not even give a clue to where I am doing wrong.
>
> Any ideas?
>
>
> Lars
> Stockholm



Reply With Quote
  #3 (permalink)  
Old 05-25-2008, 04:09 AM
Gord Dibben
 
Posts: n/a
Re: Compare Now() to a European date

As an alternative to the formulas try Data>Text to Columns>Next>Next>Column Data
Format>Date>YMD

20000524 returns May 24, 2008


Gord Dibben MS Excel MVP

On Sat, 24 May 2008 20:25:53 -0300, "Bernard Liengme"
<bliengme@stfx.TRUENORTH.ca> wrote:

>In Excel dates are stores as numbers starting from 1/1/1900
>Only formatting changes what the show as on the worksheet
>Sounds like you 20080524 is either text or just a number but not an Excel
>date
>If the entry 20000524 is text or number then
>=DATE(--LEFT(A1,4),--MID(A1,5,2),--RIGHT(A1,2))
>will give you a real date
>best wishes


Reply With Quote
  #4 (permalink)  
Old 05-25-2008, 08:08 AM
Lars
 
Posts: n/a
Re: Compare Now() to a European date

Previously, on Usenet Gord Dibben <gorddibbATshawDOTca> wrote:

>As an alternative to the formulas try Data>Text to Columns>Next>Next>Column Data
>Format>Date>YMD
>
>20000524 returns May 24, 2008


Which is exactly what I don't want it to. We do write dates as
20080524 because we think it is a better way. Our plan is to
continue doing it.

Our certificates are dated as YYYYMMDD, and since we are used
to see dates in that form I would rather not introduce another
format in a book that is all about bringing clarity to what and when.


Lars
Stockholm
Reply With Quote
  #5 (permalink)  
Old 05-25-2008, 08:15 AM
Lars
 
Posts: n/a
Re: Compare Now() to a European date

Previously, on Usenet "Bernard Liengme" <bliengme@stfx.TRUENORTH.ca>
wrote:

>In Excel dates are stores as numbers starting from 1/1/1900
>Only formatting changes what the show as on the worksheet
>Sounds like you 20080524 is either text or just a number but not an Excel
>date


No. I fill in the figures 20080524 in a cell, and it becomes a
"general" format. I can read it fine but not have Excel compare
it to a now().

When I do change the format of the cell where I have filled in
20080524 to "custom" YYYYMMDD, Excel sees it as a negative
date and shows ########

>If the entry 20000524 is text or number then
>=DATE(--LEFT(A1,4),--MID(A1,5,2),--RIGHT(A1,2))
>will give you a real date


Thank you, but on this side of the pond 20080524 is a real date.

It is not date I am after, but conditional formatting based on a date.

Lars
Stockholm
Reply With Quote
  #6 (permalink)  
Old 05-25-2008, 10:06 AM
Bob Phillips
 
Posts: n/a
Re: Compare Now() to a European date

Lars,

You could have the date fields formatted as yyyymmdd, and if you enter them
in standard date format, dd/mm/yyyy, you will see them exactly as you want,
and the conditional formatting will work.

Alternatively, you could enter them as yyyymmdd, and have event code to
reformat them and show as you want. This code will do all that and even add
the CF

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If Not IsDate(.Value) Then

.Value = DateSerial(Left$(.Value, 4), Mid$(.Value, 5, 2),
Right$(.Value, 2))
End If
.NumberFormat = "yyyymmdd"
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=AND(" & .Address(False, False)
& _
">=TODAY()," & .Address(False, False) & _
"<=DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY() )))"
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=AND(" & .Address(False, False)
& _
">=TODAY()," & .Address(False, False) & _
"<=DATE(YEAR(TODAY()),MONTH(TODAY())+3,DAY(TODAY() )))"
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions(1).Interior.ColorIndex = 6
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Lars" <Lars@fake.com> wrote in message
news:r44i349qcoi9uif0bo3iej3m1d3avbs0p0@4ax.com...
> Previously, on Usenet "Bernard Liengme" <bliengme@stfx.TRUENORTH.ca>
> wrote:
>
>>In Excel dates are stores as numbers starting from 1/1/1900
>>Only formatting changes what the show as on the worksheet
>>Sounds like you 20080524 is either text or just a number but not an Excel
>>date

>
> No. I fill in the figures 20080524 in a cell, and it becomes a
> "general" format. I can read it fine but not have Excel compare
> it to a now().
>
> When I do change the format of the cell where I have filled in
> 20080524 to "custom" YYYYMMDD, Excel sees it as a negative
> date and shows ########
>
>>If the entry 20000524 is text or number then
>>=DATE(--LEFT(A1,4),--MID(A1,5,2),--RIGHT(A1,2))
>>will give you a real date

>
> Thank you, but on this side of the pond 20080524 is a real date.
>
> It is not date I am after, but conditional formatting based on a date.
>
> Lars
> Stockholm




Reply With Quote
  #7 (permalink)  
Old 05-25-2008, 11:05 AM
Bob Phillips
 
Posts: n/a
Re: Compare Now() to a European date

Couple of problems with my code, fixed here

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If Not IsDate(.Value) Then

.Value = DateSerial(Left$(.Value, 4), Mid$(.Value, 5, 2),
Right$(.Value, 2))
End If
.NumberFormat = "yyyymmdd"
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=AND(" & .Address(False, False)
& _
">=TODAY()," & .Address(False, False) & _
"<=DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY() )))"
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=AND(" & .Address(False, False)
& _
">=TODAY()," & .Address(False, False) & _
"<=DATE(YEAR(TODAY()),MONTH(TODAY())+3,DAY(TODAY() )))"
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions(2).Interior.ColorIndex = 6
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Lars" <Lars@fake.com> wrote in message
news:r44i349qcoi9uif0bo3iej3m1d3avbs0p0@4ax.com...
> Previously, on Usenet "Bernard Liengme" <bliengme@stfx.TRUENORTH.ca>
> wrote:
>
>>In Excel dates are stores as numbers starting from 1/1/1900
>>Only formatting changes what the show as on the worksheet
>>Sounds like you 20080524 is either text or just a number but not an Excel
>>date

>
> No. I fill in the figures 20080524 in a cell, and it becomes a
> "general" format. I can read it fine but not have Excel compare
> it to a now().
>
> When I do change the format of the cell where I have filled in
> 20080524 to "custom" YYYYMMDD, Excel sees it as a negative
> date and shows ########
>
>>If the entry 20000524 is text or number then
>>=DATE(--LEFT(A1,4),--MID(A1,5,2),--RIGHT(A1,2))
>>will give you a real date

>
> Thank you, but on this side of the pond 20080524 is a real date.
>
> It is not date I am after, but conditional formatting based on a date.
>
> Lars
> Stockholm



Reply With Quote
  #8 (permalink)  
Old 05-25-2008, 11:45 AM
Dave Peterson
 
Posts: n/a
Re: Compare Now() to a European date

The value that the cell holds and what you see in the cell don't have to match.

Enter the date as a real date--match your windows short date settings.

But then format the cell to show yyyymmdd.

You'll see a difference between what's in the formula bar and what's displayed
in the cell.

Gord's suggestion was a way to convert those numbers (not really dates) to real
dates so that you could format them the way you want.

ps. It's not really showing a negative date (when you see ###'s). It's just
that 20080524 is out of the range of what dates excel supports.

In excel, dates are just counts from a base date (usually Dec 31, 1899 in the
wintel world). That 20080524 is 20,080,524 days since Dec 31, 1899.



Lars wrote:
>
> Previously, on Usenet Gord Dibben <gorddibbATshawDOTca> wrote:
>
> >As an alternative to the formulas try Data>Text to Columns>Next>Next>Column Data
> >Format>Date>YMD
> >
> >20000524 returns May 24, 2008

>
> Which is exactly what I don't want it to. We do write dates as
> 20080524 because we think it is a better way. Our plan is to
> continue doing it.
>
> Our certificates are dated as YYYYMMDD, and since we are used
> to see dates in that form I would rather not introduce another
> format in a book that is all about bringing clarity to what and when.
>
> Lars
> Stockholm


--

Dave Peterson
Reply With Quote
  #9 (permalink)  
Old 05-26-2008, 03:14 AM
=?Utf-8?B?U2hhbmVEZXZlbnNoaXJl?=
 
Posts: n/a
RE: Compare Now() to a European date

Hi Lars,

This looks like an ISO date issue. I have developed a file which
demonstrates ISO date conversions. In it there are spreadsheet formulas or
VBA functions. If you are interested contact me.

--
Cheers,
Shane Devenshire
shanedevenshire@sbcglobal.net

"Lars" wrote:

> This is driving me nuts,
>
> I have a list of certificates. In column B their expiry dates are
> entered as Europeans, some at least, do. Like today would be 20080524.
>
> I want these cells to change colour with conditional formating.
> For instance becoming yellow when there is less than three months
> between now and the expiry date, and then becoming red when there
> is less than one month to expiry. Else they should remain without
> colour.
>
> I have read through a hundred posts dealing with similar needs and
> seemingly fine replies, but I get nowhere with my particular sheet.
>
> When I format my B cell as "custom" yyyymmdd and enter my date
> Excel says that negative dates are displayed as ##########.
> When I leave its format as "general" the cells become red whatever
> number I enter there.
>
> I have tried having a now-function in a separate cell and comparing my
> B's to it, but it does not even give a clue to where I am doing wrong.
>
> Any ideas?
>
>
> Lars
> Stockholm
>

Reply With Quote
  #10 (permalink)  
Old 05-26-2008, 12:40 PM
Mais qui est Paul
 
Posts: n/a
Re: Compare Now() to a European date

Bonsour® Lars avec ferveur ;o))) vous nous disiez :

> This is driving me nuts,

;o)))
> I have a list of certificates. In column B their expiry dates are
> entered as Europeans, some at least, do. Like today would be 20080524.
>
> I want these cells to change colour with conditional formating.
> For instance becoming yellow when there is less than three months
> between now and the expiry date, and then becoming red when there
> is less than one month to expiry. Else they should remain without
> colour.


I supppose column "B" format is Standard

Select (Format > Conditional Formatting) to display the Conditional Formatting dialog box.
Condition 1
Select "Formula Is" in the first drop-down box and enter the formula
=TODAY() < DATE(INT(B1 / 10000) , 3 + MOD(INT(B1 / 100) , 100) , MOD(B1 , 100))
Click the Format button to apply your specific formatting


HTH
--
@+
;o)))
Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 03:11 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Gas Suppliers | Cash ISA | Myspace Layouts | Advertising | Car Finance



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114