Page 1 of 1
Day of week -1
Posted: Wed Sep 12, 2012 6:31 am
by monahanks
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,
Re: Day of week -1
Posted: Thu Sep 13, 2012 8:24 am
by monahanks
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.
Re: Day of week -1
Posted: Thu Sep 13, 2012 8:34 am
by Support_Rick
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/post ... 471cc#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>