Expand my Community achievements bar.

Build a date

Avatar

Former Community Member

This is an offshoot of the thread on the date bug.  Since it is a different topic, I thought it deserved its own thread.

I want to build a date, but I don't see any constructor in FormCalc to do that.  Is this just my missing it or doesn't it exist.

Using Date2Num I can extract the pieces of a date (month, day, year).  Because of the date bug I can't do the simple of adding one to a date without tons of scripting behind it.  Each of the date delimiters has multiple options (mm,dd,yy or m,dd,yy or mm,d,yy or m,d,yy or mm,dd,yyyy or m,dd,yyyy or mm,d,yyyy or dd,mm,yy or m,dd,yyyy etc.  And each of these apply to period, comma, dash, slash or space delimiters.  A script could run to hundreds of lines to accommodate all this.

I was hoping to have a work-a-round by extracting the pieces and ignoring the delimiters and permutations.  The problem is building the date from the pieces.

One format in the docs is Num2Date("12/31/12", "MM/DD/YY") so I was hoping to create a variable with that and use it.  But it didn't work.

Any ideas on:

1) other utilities that will convert numbers into a date?

2) a correct format for this utility?

Here is the code I have so far:

var day = Num2Date(monAsNum, "D");

var month = Num2Date(monAsNum, "M");

var year = Num2Date(monAsNum, "Y");

var redone = Concat(month,"/",day+1,"/",year);

var rebuild = Num2Date(redone,"MM/DD/YYYY");   

$host.messageBox(Concat("Testing **Day: ", day, " Month: ", month, " Year: ", year, " Rebuilt: ", rebuild));

I also concatenated in a double quote to the string start and end, but it still didn't work.

0 Replies