Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question with Date Handling

Status
Not open for further replies.

Volkmaniac

Technical User
Mar 19, 2003
104
US
I'm trying to run a script that will initiate a PROC in program. The PROC will do a PICK on a series of accounts within a specified date period. I was wondering if I can use aspect to assign that date for a fixed period before the current date. In other words, I need the date to always be 180 days before the current date. Does aspect allow for this type of date handling?

$DATE - 180

I don't have a clue how I'd do this.
 
Here's a script that shows one way of doing this:

proc main
long lCurTime
integer iMonth, iDay, iYear, iHour, iMin, iSec
string sDate

lCurTime = $LTIME - 180 * (86400)
ltimeints lCurTime iYear iMonth iDay iHour iMin iSec
strfmt sDate "%02d/%02d/%d" iMonth iDay iYear
usermsg "%s" sDate
endproc

It takes the current time/date ($LTIME system variable) and subtracts the number of seconds in 180 days (86400 is the number of seconds in a day). It then breaks that value into month, day, etc. then creates a string variable containing the date 180 days ago. The string is in MM/DD/YYYY format, but can be easily changed by modifying the format string in the strfmt command.


aspect@aspectscripting.com
 
Knob,

That works great. Is there anyway I can insert those dates within a PICK statement? This is what I have below. It obviously doesn't work because transmit will literally enter whatever is typed. Is there a way I can get that date inserted in the last statement?

proc main

long lCurTime,lCurTime2
integer iMonth, iDay, iYear, iHour, iMin, iSec
string sDate,sDate2

lCurTime = $LTIME - 180 * (86400)
ltimeints lCurTime iYear iMonth iDay iHour iMin iSec
strfmt sDate "%02d-%02d-%d" iMonth iDay iYear
strdelete sDate 7 2
usermsg "%s" sDate
transmit "^M"


lCurTime2 = $LTIME - 30 * (86400)
ltimeints lCurTime2 iYear iMonth iDay iHour iMin iSec
strfmt sDate2 "%02d-%02d-%d" iMonth iDay iYear
strdelete sDate2 7 2
usermsg "%s" sDate2
transmit "^M"

clear
transmit "^M"
transmit "SELECT DEBTOR WITH 10 `"20`"`"13`"`"7`"`"31`"^M"

waitfor ">>" forever

transmit "SL EMOVE^M"
waitfor ">>"
rget sResponse
strdelete sResponse 0 3

usermsg "Your list name will be %s" sResponse
pause 2
transmit "^M"
transmit "GL EMOVE^M"
waitfor ">>"

transmit "SELECT DEBTOR WITH 14 LE `"sDate`" AND WITH PRIORITY NE `"-99`" AND WITH PRIORITY NE `"1`" AND WITH 13 LE `"sDate2`" AND WITHOUT 72 AND WITHOUT 48^M"


endproc





 
You can use the strfmt command to create a string using a format string and one or more variables. Here's how you would it do it in your situation:

strfmt sCommand "SELECT DEBTOR WITH 14 LE %s AND WITH PRIORITY NE `"-99`" AND WITH PRIORITY NE `"1`" AND WITH 13 LE %s AND WITHOUT 72 AND WITHOUT 48^M" sDate sDate2

You would then just use transmit sCommand to send the entire string with the values of sDate and sDate2 inserted.


aspect@aspectscripting.com
 
Worked perfect. Thanks again. I'm glad this site is up and running again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top