Day of week -1

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.

Day of week -1

Postby monahanks » Wed Sep 12, 2012 6:31 am

Hi, I couldn't find this in the forum. I have a project that retrieves the day of the week (ex Mon, Tue, Fri) using a timestamp task. Is there a way to get yesterday's day of week name? For example, if the project runs at 01:30am on Wednesday, I want to retrieve the value of Tue. Would this be a 2 or 3 step process - retrieve today's date, subtract one and then retrieve the day of week?
Thanks,
monahanks
 
Posts: 25
Joined: Wed Mar 30, 2011 10:19 am

Re: Day of week -1

Postby monahanks » Thu Sep 13, 2012 8:24 am

Thanks Duane, I've got to stop being so lazy.
Using the date manipulation tab, entering "-1" into the Day of Month value will return the previous day's day name.
monahanks
 
Posts: 25
Joined: Wed Mar 30, 2011 10:19 am

Re: Day of week -1

Postby Support_Rick » Thu Sep 13, 2012 8:34 am

The easiest way to do Date Arithmetic is to use SQL. To achieve the date calculations you're looking for you can perform the following:

Select DayName( Current_Date - 1 Day), Current_Date - 1 Day from SysIBM.SysDummy1

Note: This assumes that you're using an iSeries. SysDummy1 can be replaced by any SQL Table that has at least 1 record in that table.

There is a post on the Forum that eluded to a Utility Project called SQL Help. This utility allowed you to pass any valid SQL Select statement and get a returned value. You can see the Project in this post:

http://www.goanywheremft.com/forum/post418.html?sid=7b2c13876dad8283cef330a8b95471cc&sid=7b2c13876dad8283cef330a8b95471cc#p418

This would allow you to do something like:

Code: Select all
<callProject label="SQL Help" version="1.0" project="/Utilities/SQL Help" runInSameJob="true" inheritUserVariables="true" returnUserVariables="true" onError="setVariable:Error=1">
   <variable name="SQLStmt" value="( Current_Date - 1 Day )" />
   <variable name="Reply"   value=" " />
</callProject>
<setVariable label="Set Yesterday" version="1.0" name="Yesterday" value="${Reply}"/>

<callProject label="SQL Help" version="1.0" project="/Utilities/SQL Help" runInSameJob="true" inheritUserVariables="true" returnUserVariables="true" onError="setVariable:Error=1">
   <variable name="SQLStmt" value="( DayName( Current_Date - 1 Day ) )" />
   <variable name="Reply"   value=" " />
</callProject>
<setVariable label="Set DayName" version="1.0" name="DayName" value="${Reply}"/>

<print label="Status" version="1.0">
<![CDATA[
*===========================================================================================*
Yesterday was ${ DayName } - ${ Yesterday }
*===========================================================================================*
]]>
</print>

Rick Elliott
Sr. Product Specialist
(402) 944.4242
(800) 949-4696
Support_Rick
Support Specialist
 
Posts: 171
Joined: Tue Jul 17, 2012 2:12 pm


Return to Community Forum

Who is online

Users browsing this forum: No registered users and 1 guest