Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Dates

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 23rd, 2012, 07:07 PM
Sean Sean is offline
Forum n00b
 
Join Date: Sep 2011
Posts: 8
Default Need help trying to format a date

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
__________________

FusionPro VDP Creator 10.0.3
Acrobat 11.0.07
macOS 10.12.3
Reply With Quote
  #2  
Old May 24th, 2012, 07:36 AM
dreimer dreimer is offline
Senior Contributor
 
Join Date: Oct 2010
Location: Shakopee, MN
Posts: 496
Default Re: Need help trying to format a date

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.
__________________
Don Reimer - JavaScript Novice

MAC OS 10.14.6 Acrobat DC FP Creator 12.0.1
Reply With Quote
  #3  
Old May 24th, 2012, 09:23 AM
FreightTrain's Avatar
FreightTrain FreightTrain is offline
Learning Development Manager
 
Join Date: Oct 2008
Location: Solana Beach, CA
Posts: 326
Default Re: Need help trying to format a date

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")'

Quote:
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.
__________________
Richard A. Lewis, Jr.
Learning Development Manager | MarcomCentral® a Ricoh Company
Reply With Quote
  #4  
Old May 24th, 2012, 09:52 AM
ehazzard's Avatar
ehazzard ehazzard is offline
Contributor
 
Join Date: Oct 2008
Location: Solana Beach, CA
Posts: 40
Default Re: Need help trying to format a date

This can also be done with a simple text rule as well:



Quote:
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.
Reply With Quote
  #5  
Old May 24th, 2012, 11:14 AM
FreightTrain's Avatar
FreightTrain FreightTrain is offline
Learning Development Manager
 
Join Date: Oct 2008
Location: Solana Beach, CA
Posts: 326
Default Re: Need help trying to format a date

Suuuurrrrreeee take the easy way.
__________________
Richard A. Lewis, Jr.
Learning Development Manager | MarcomCentral® a Ricoh Company
Reply With Quote
  #6  
Old June 4th, 2012, 03:20 PM
Sean Sean is offline
Forum n00b
 
Join Date: Sep 2011
Posts: 8
Default Re: Need help trying to format a date

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.
__________________

FusionPro VDP Creator 10.0.3
Acrobat 11.0.07
macOS 10.12.3
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:00 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.