Sean Posted May 24, 2012 Share Posted May 24, 2012 Hello, I am trying to figure out how to write a rule for formatting a date. Date = 06/01/2012 and should return a value of "Friday, June 1". Any help would be greatly appreciated. Thank you, Sean Link to comment Share on other sites More sharing options...
dreimer Posted May 24, 2012 Share Posted May 24, 2012 I would like to see how to do this as well. It looks like the built in rules only allow for using the date as integers. Link to comment Share on other sites More sharing options...
FreightTrain Posted May 24, 2012 Share Posted May 24, 2012 Sean, The 'getDay()' function returns the day of the week as an integer, with 0 being Sunday and 6 being Saturday. To get the day of the week you need to use an array to equate the number for the day of the week with the actual day. Then you need to apply the date format function to the field providing the date value. In the example below I just used 'Today()', but this could be 'Field("Event Date")' var theDate=new Date(Today()); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; var newDate = weekday[theDate.getDay()]; return newDate+", "+FormatDate(Today(), "lm, d"); Hope this helps. Link to comment Share on other sites More sharing options...
ehazzard Posted May 24, 2012 Share Posted May 24, 2012 This can also be done with a simple text rule as well: return FormatDate(Field("Date"), "ld, lm d"); This rule takes the variable "date" and formats using the Long Day(ld) comma Long Month(lm) and the day(d). All formatting in the quotes will be returned as literal text; this is a pre-built rule in the Building Blocks under the Functions tab > date. Link to comment Share on other sites More sharing options...
FreightTrain Posted May 24, 2012 Share Posted May 24, 2012 Suuuurrrrreeee take the easy way. Link to comment Share on other sites More sharing options...
Sean Posted June 4, 2012 Author Share Posted June 4, 2012 Sorry for not replying sooner. Thank you guys for your help. All i can say is that this forum is super helpful and full of great information. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.