Date

Post your questions and help other users.

Moderator: Martin

Post Reply
Atbl
Posts: 14
Joined: 04 Dec 2015 16:26

Date

Post by Atbl » 15 Dec 2015 14:12

Hi,
I wad trying to display the date of previous day and I am successful also. But the problem is that I want to show like this:-
1st
2nd
3rd
4th
5th
:
:
:
31st
After 1, it should show 'st'
After 2, it should show 'nd'
And so on......
In every date it is only showing only 'th'.
Please Help!!

http://automagic4android.com/flow.php?i ... c5dc2030d6

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Date

Post by Martin » 16 Dec 2015 20:16

Hi,

There needs to be a slight modification in your script:
today = getDate();
today = addDays(today, -1);
daym = "{today,dateformat,d}";
if(daym == '1'){
finalDate = "{today,dateformat, '1st' MMMM yyyy}";
}else if(daym == '2'){
finalDate = "{today,dateformat, '2nd' MMMM yyyy}";
}else if(daym == '3'){
finalDate = "{today,dateformat, '3rd' MMMM yyyy}";
}else{
finalDate = "{today,dateformat,  dd'th' MMMM yyyy}";
}
Mainly the formatting of daym seems to be wrong in the shared flow.
I just changed the formatting of daym to use one digit for the day and use the single number also in the if-checks.

Regards,
Martin

Post Reply