These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Question: Regarding If and Dates

dk3dknight
Registered: Jan 22 2008
Posts: 136
Answered

What im trying to do is check a date field to see if the date has not happened yet.

This is on a pilot application, I have a date Field called DateIssued1, I wanted to check to see if the data had not happened yet, by checking against the current computers clock.

(this is form calc btw)

//
if (DateIssued1 > Date2Num(Date(),"MM/DD/YYYY")) then
DateIssued1 = "*Invalid*"
endif
//

Now I thought that might work, but it doesn't, now there is no error either,
so maybe my principle is right but im not quite there.

Anyone have any input on this?

Or am I seeking the impossible road?

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Character strings are compared from the left to the right, with the first left most character in an equal length string determining the sequence order. So if one wants to compare date strings the first portion to be compared should be the 4 digit year then the 2 digit month and finally the 2 digit day.

Since one would need to reformat the date string to number and then to a new date sting and convert the current date to a date string, why not avoid one of the conversions and just deal with the dates as numbers.

"Date()" returns the number of days since the fixed epoch date and "Date2Num()" will return the number of days from the same epoch date of the passed date string. Now you can now do a simple numeric comparison to get your answer.

George Kaiser

dk3dknight
Registered: Jan 22 2008
Posts: 136
Im sorry I dont quite follow, programming is not really my forte could you um simplify that for me?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Compare the dates the number of days and not a character strings.

//
if (Dated2Num(DateIssued1, "MM/DD/YYYY") > Date() ) then
DateIssued1 = ""
$host.messageBox( "Inputted date must be before today's date!", "Invalid Date", 1)
endif
//

George Kaiser

dk3dknight
Registered: Jan 22 2008
Posts: 136
Thank You thats pure genius!

Im sorry that my mindset is probably not the best,
thank you for working with me on this.