View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default date format in excel 2002 on win 7

on this forum a helpful expert posted
With a value in A1:
=A1&IF(AND(A110,A1<20),"th",CHOOSE(MOD(A1,10)+1,"
th","st","nd","rd","th","th","th","th","th","th" ))

with my version i get 10 th not 10th
same with 20.
so i changed the formula 10 and 20 to 9 and 19. worked but 30th is
still 30 th!
what do i do?
and can i change a date say january 20 2006 and using this formula to
get January 20th 2006, all in one cell?
i need to copy paste them into a text file.
thanks all


Assuming A1 contains only the day value...

=A1&IF(AND(RIGHT(A1,1)="1",RIGHT(A1,2)<"11"),"st" ,IF(AND(RIGHT(A1,1)="3",OR(A1<10,A120)),"rd",IF(A ND(RIGHT(A1,1)="2",OR(A1<3,A120)),"nd",IF(AND(A1 9,A1<21),"th","th"))))

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion