Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default =IF(test,true,false) only ever returns "true"?

A little help please. I have data imported to Excel from a legacy app. Some
DOB is a length of 7, e.g. 1012008 and some DOB is a length of 8, e.g.
11012008. Neither formula following is working for me:


=IF( (LEN(B4=8)),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )


=IF( (LEN(B4=7)), (LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)) )

If I test for a length of eight and the date is 11012008 I get 11/01/2008,
which is good. However, if the date is 1012008 I get 10/12/2008, which is
not good.

If I test for a length of seven and the date is 11012008 I get 1/10/2008,
which is not good. However if the date is 1012008 I get 1/01/2008, which is
good.

It seems I only ever get the "true" formulation. Any thoughts? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,440
Default =IF(test,true,false) only ever returns "true"?

You have the bracker for the LEN function in the wrong place.
Try this:
=IF( (LEN(B4)=8),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"&
RIGHT(B4,4)),(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )
There are still more brackets than necessary, BTW

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"TagTech" wrote in message
...
A little help please. I have data imported to Excel from a legacy app.
Some
DOB is a length of 7, e.g. 1012008 and some DOB is a length of 8, e.g.
11012008. Neither formula following is working for me:


=IF( (LEN(B4=8)),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )


=IF( (LEN(B4=7)), (LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)) )

If I test for a length of eight and the date is 11012008 I get 11/01/2008,
which is good. However, if the date is 1012008 I get 10/12/2008, which is
not good.

If I test for a length of seven and the date is 11012008 I get 1/10/2008,
which is not good. However if the date is 1012008 I get 1/01/2008, which
is
good.

It seems I only ever get the "true" formulation. Any thoughts? Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default =IF(test,true,false) only ever returns "true"?

You have the LEN test *inside* the LEN function. Move it outside the LEN
function. Also, your formula returns a *TEXT* string that looks like a date
but is not a true Excel data.

Try this:

=--TEXT(IF(LEN(B4)=7,"0"&B4,B4),"00\/00\/0000")

Format in the Date style of your choice for a true Excel date.

--
Biff
Microsoft Excel MVP


"TagTech" wrote in message
...
A little help please. I have data imported to Excel from a legacy app.
Some
DOB is a length of 7, e.g. 1012008 and some DOB is a length of 8, e.g.
11012008. Neither formula following is working for me:


=IF( (LEN(B4=8)),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )


=IF( (LEN(B4=7)), (LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)) )

If I test for a length of eight and the date is 11012008 I get 11/01/2008,
which is good. However, if the date is 1012008 I get 10/12/2008, which is
not good.

If I test for a length of seven and the date is 11012008 I get 1/10/2008,
which is not good. However if the date is 1012008 I get 1/01/2008, which
is
good.

It seems I only ever get the "true" formulation. Any thoughts? Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default =IF(test,true,false) only ever returns "true"?

"T. Valko" wrote...
....
Try this:

=--TEXT(IF(LEN(B4)=7,"0"&B4,B4),"00\/00\/0000")


Prepending 0 unnecessary.

TEXT("1232009","00\/00\/0000") and TEXT("01232009","00\/00\/0000")
both return "01/23/2009".
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default =IF(test,true,false) only ever returns "true"?

"Harlan Grove" wrote in message
...
"T. Valko" wrote...
...
Try this:

=--TEXT(IF(LEN(B4)=7,"0"&B4,B4),"00\/00\/0000")


Prepending 0 unnecessary.

TEXT("1232009","00\/00\/0000") and TEXT("01232009","00\/00\/0000")
both return "01/23/2009".


That makes it even better. As long as the number format is mddyyyy or
mmddyyyy:

=--TEXT(B4,"00\/00\/0000")


--
Biff
Microsoft Excel MVP




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default =IF(test,true,false) only ever returns "true"?

Thanks. Never would have seen that. Like a missing period in COBOL. Used
"extra" brackets to try to separate code so I could find my mistake, but as I
said, I never would have seen that it should be LEN(B4)=8 instead of
LEN(B4=8). Preciate!

"Niek Otten" wrote:

You have the bracker for the LEN function in the wrong place.
Try this:
=IF( (LEN(B4)=8),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"&
RIGHT(B4,4)),(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )
There are still more brackets than necessary, BTW

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"TagTech" wrote in message
...
A little help please. I have data imported to Excel from a legacy app.
Some
DOB is a length of 7, e.g. 1012008 and some DOB is a length of 8, e.g.
11012008. Neither formula following is working for me:


=IF( (LEN(B4=8)),(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)) )


=IF( (LEN(B4=7)), (LEFT(B4,1) &"/"& MID(B4,2,2) &"/"& RIGHT(B4,4)),
(LEFT(B4,2) &"/"& MID(B4,3,2) &"/"& RIGHT(B4,4)) )

If I test for a length of eight and the date is 11012008 I get 11/01/2008,
which is good. However, if the date is 1012008 I get 10/12/2008, which is
not good.

If I test for a length of seven and the date is 11012008 I get 1/10/2008,
which is not good. However if the date is 1012008 I get 1/01/2008, which
is
good.

It seems I only ever get the "true" formulation. Any thoughts? Thanks.


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
Disable autoformat of "true" and "false" text drs207 Excel Discussion (Misc queries) 6 April 14th 23 05:33 PM
=IF(VLOOKUP(C11,Group,2,FALSE)=D11,"True","Not Valid") and =IF(D1 Milky Excel Worksheet Functions 1 August 20th 08 08:38 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Typing "true" excel 2007 change it to "TRUE" Mr. T Excel Discussion (Misc queries) 2 April 11th 07 01:24 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 08:58 PM.

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

About Us

"It's about Microsoft Excel"