INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Just Nearly Completed My Image Caption :)  (Read 2158 times)

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Just Nearly Completed My Image Caption :)
« on: March 13, 2012, 09:16:57 pm »

I've just finished my images caption (I know it looks messy but it is this way so that certain elements don't appear on the same line)

I like the new ifelse feature. I've managed to make a caption that would otherwise be extremely difficult.

If the output of the day is 01 it outputs 01st

and if 02 it outputs 02nd,
and if 03 it ouputs 03rd,
and if 21 it ouputs 21st
and if 22 it ouputs 22nd
and if 23 it ouputs 23rt
and if 31 it ouputs 31st
and if day equals any other it outputs [day]th

The part I'd like help with is the date I've got it working there is just one little tweak I'd like to do.
The part that outputs the day to a double digit, if the number is from 01 - 09 remove the 0 digit from it. Would it be hard to do/worth while). I don't know I just don't like the look of left trailing zeros.

Code: [Select]
if(isempty([date]),,formatdate([date,0],dddd the formatdate([date,0],dd,),)ifelse(isequal(formatdate([date,0],dd,),01,2),st,isequal(formatdate([date,0],dd,),02,2),nd,isequal(formatdate([date,0],dd,),03,2),rd,
isequal(formatdate([date,0],dd,),21,2),st,isequal(formatdate([date,0],dd,),22,2),nd,isequal(formatdate([date,0],dd,),23,2),rd,isequal(formatdate([date,0],dd,),31,2),st,1,th)
 formatdate([date,0],MMMM,) formatdate([date,0],yyyy,)
)if(isempty([caption]),,[caption])
if(isempty([places]),,[places])
if(isempty([people]),,replace([people],;,/ &))

Thanks
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Just Nearly Completed My Image Caption :)
« Reply #1 on: March 13, 2012, 09:28:20 pm »

Use one 'd' instead of two.
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Just Nearly Completed My Image Caption :)
« Reply #2 on: March 13, 2012, 09:36:11 pm »

You can do that??

This is all the wiki says
Quote
yy Returns the last two digits of the year
yyyy Returns the full year
MM Returns the month as two digits
MMM Returns the month as three letter abbreviations
MMMM Returns the month in full
dd Returns the day as two digits
ddd Returns the day as three letter abbreviations
dddd Returns the full day
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Just Nearly Completed My Image Caption :)
« Reply #3 on: March 13, 2012, 10:51:57 pm »

By the way, try this:


ifelse(isempty(formatdate([date,0],d)), No Day Defined,
          regex(formatdate([date,0],d), /#^(1|21|31)$#/), [R1]st,
          regex(formatdate([date,0],d), /#^(2|22)$#/), [R1]nd,
          regex(formatdate([date,0],d), /#^(3|23)$#/), [R1]rd,
          1, formatdate([date,0],d)th)
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Just Nearly Completed My Image Caption :)
« Reply #4 on: March 13, 2012, 10:52:32 pm »

You can do that??

This is all the wiki says

Break the rules, live on the edge.
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Just Nearly Completed My Image Caption :)
« Reply #5 on: March 14, 2012, 04:57:40 am »

ok lol, it worked :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Just Nearly Completed My Image Caption :)
« Reply #6 on: March 14, 2012, 11:01:35 am »

Btw. here's another way to get your English days listed from the date:

Quote
if(isempty(formatdate([date,0],d)), No Day Defined, listitem(NA;1st;2nd;3rd;4th;5th;6th;7th;8th;9th;10th;11th;12th;13th;14th;15th;16th;17th;18th;19th;20th;21st;22nd;23rd;24th;25th;26th;27th;28th;29th;30th;31st, formatdate([date,0],d), ;))
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Just Nearly Completed My Image Caption :)
« Reply #7 on: March 14, 2012, 02:48:41 pm »

Brian0001,

In another thread, Vagskal brings to my attention that you can simplify this expression by moving some of it to a calculated field.  By assigning the value:

NA;1st;2nd;3rd;4th;5th;6th;7th;8th;9th;10th;11th;12th;13th;14th;15th;16th;17th;18th;19th;20th;21st;22nd;23rd;24th;25th;26th;27th;28th;29th;30th;31st

to a new calculated field, say [Days w-Suffix], you can then use the simpler expression:

if(isempty(formatdate([date,0],d)),
  No Day Defined,
  listitem([Days w-Suffix], formatdate([date,0],d), ;))

Essentially, [Days w-Suffix] becomes a global value you can use in your expressions to simplify them.
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Just Nearly Completed My Image Caption :)
« Reply #8 on: March 14, 2012, 04:01:13 pm »

Thanks again MrC, got my caption updated, very happy :)
Logged
Pages: [1]   Go Up