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

Adding / subtracting days from Current Date

mgrahams
Registered: May 5 2009
Posts: 6
Answered

I've been trying to figure out how to subtract 180 days from the Current Date and can't figure it out. No problems subtracting days from a user entered date in a subform:

var current = Date2Num(DelivDate.formattedValue, "MM/DD/YY")
var date1 = current-180
var date2 = current-365
var newDate1 = Num2Date(date1, "MM/DD/YY")
var newDate2 = Num2Date(date2, "MM/DD/YY")

F.P1.Subform1.TestDate1.rawValue = newDate1
F.P1.Subform1.TestDate2.rawValue = newDate2

This coding doesn't work when I substitute "CurrentDate" in place of "DelivDate". Can anyone tell me what I'm missing?

Thanks,
Matt

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
How is the value of the 'CurrentDate' field being set?

Does 'CurrentDate" have any value?

var current = Date2Num(DelivDate.formattedValue, "MM/DD/YY")xfa.host.messageBox(Concat("DelivDate = ", DelivDate.formattedValue, " number: ", current ), 0, 3)var date1 = current - 180var date2 = current - 365var newDate1 = Num2Date(date1, "MM/DD/YY")var newDate2 = Num2Date(date2, "MM/DD/YY")xfa.host.messageBox(Concat("date1 = ", date1, " formatted: ", newDate1), 0, 3)xfa.host.messageBox(Concat("date2 = ", date2, " formatted: ", newDate2), 0, 3) var NowDate = Date()var CurrentDate = Num2Date(NowDate, "MM/DD/YY")current = Date2Num(CurrentDate, "MM/DD/YY")xfa.host.messageBox(Concat("CurrentDate: ", CurrentDate, "number: ", current), 0, 3)date1 = current - 180xfa.host.messageBox(Concat("CurrentDate - 180  = ", date1, " formatted: ", Num2Date(date1, "MM/DD/YY") ), 0, 3)date2 = current - 365xfa.host.messageBox(Concat("CurrentDate - 365  = ", date2, " formatted: ", Num2Date(date2, "MM/DD/YY") ), 0, 3)

George Kaiser

mgrahams
Registered: May 5 2009
Posts: 6
The message boxes seem correct they contain the date & corresponding number. However, how would I display the number by itself or date by itself in a text box within the same subform? I have a calculation in a seperate part of the form that calculates one price based upon DelivDate being within 180 days and a different price if its 365 days from CurrentDate. Comparing numbers say: 39937 (May 5, 2009) to 39674 (Aug 15, 2008) seems easier than comparing dates.Thank you so much for your help.
mgrahams
Registered: May 5 2009
Posts: 6
I answered my question. Thanks for your help.