Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


itellium
2015-01-07T07:32:57Z
If 7.1.2015 then " {DATENOWADD(Weeks|-1|yyyy)}" return 2014 although "{MATH(Add|Integer|{DATE(Week)}|-1|#00)}" return 01.
I expect function DATENOWADD return 2015 and not 2014.
Sponsor
Forum information
Support
2015-01-07T09:33:23Z
The weeks function is similar to day function but represents 7 days. So if you subtract 7 days from 2015-01-07 you will end up on date 2014-12-31.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2015-01-07T09:34:42Z
I understand the problem though and we will look at it.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2015-01-07T09:39:43Z
We are not sure how to handle exactly yet. Let say you want to display the the full date with your variable, like this:

{DATENOWADD(Weeks|-1|yyyy-MM-dd)}

Then, what dd value should be used? First day of week or last day? Or?

If we change this is any way we are changing that one week back might be less than 7 days - if you see what we mean.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-01-07T10:34:18Z
It is based on actual date. When "{MATH(Add|Integer|{DATE(Week)}|-1|#00)}" returns 01 then I want in another variable the year of this calendar week.......2015 and not 2014. How I have to code it?
Support
2015-01-07T10:58:38Z
I do not see any direct solution for this but I wrote a quick .NET code which you can use in the .NET Code Task (VB.NET)

    Public Shared Function GetYearFromAddWeek(addWeek As Integer, format As String) As String
        Dim ci As Globalization.CultureInfo = Threading.Thread.CurrentThread.CurrentCulture
        Dim currentWeek As Integer = ci.Calendar.GetWeekOfYear(DateTime.Now, ci.DateTimeFormat.CalendarWeekRule, ci.DateTimeFormat.FirstDayOfWeek)
        If (currentWeek + addWeek) <= 0 Then
            Return DateTime.Now.AddYears(-1).ToString(format)
        ElseIf (currentWeek + addWeek) > 52 Then
            Return DateTime.Now.AddYears(1).ToString(format)
        Else
            Return DateTime.Now.ToString(format)
        End If
    End Function

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-01-07T15:26:05Z
Thanks! But I do not know .NET Code Task. What must I do to call function GetYearFromAddWeek. Is there a tutorial how to include .NET code? I tried ".NET code execute" but got error message "....dll" not found.
Support
2015-01-08T10:33:55Z
Here is a video showing:

http://screencast.com/t/kHQqjCBZ 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-01-16T10:50:28Z
Thank for video. But .NET code doesn't work. See attached pictures.
itellium attached the following image(s):
Support
2015-01-16T16:19:51Z
What values did you use in the parameters?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-01-22T07:24:22Z
I am not able to edit parameter in task ".NET code execute – show year of last calendar week". See second screenshot above too.
Support
2015-01-22T08:31:30Z
You need to increase the size of the window and you will see the list of parameters.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-02-24T10:02:19Z
After increasing window I saw both parameter were empty. So I set format to yyyy and addweek to 1 because I am not able to place {MATH(Add|Integer|{DATE(Week)}|-1|#00)} into variable addweek and tested the NET code. It functions - I get 2015 :-)
But when I tried in next task {STRING(Replace|{NEWNAME()}|_Y_|_{GetYearFromAddWeek({MATH(Add|Integer|{DATE(Week)}|-1|#00)},yyyy)} it doesn't function. What is the correct way?
Support
2015-02-24T11:23:37Z
Originally Posted by: itellium 

After increasing window I saw both parameter were empty. So I set format to yyyy and addweek to 1 because I am not able to place {MATH(Add|Integer|{DATE(Week)}|-1|#00)} into variable addweek and tested the NET code. It functions - I get 2015 :-)
But when I tried in next task {STRING(Replace|{NEWNAME()}|_Y_|_{GetYearFromAddWeek({MATH(Add|Integer|{DATE(Week)}|-1|#00)},yyyy)} it doesn't function. What is the correct way?



I am not sure I understand. GetYearFromAddWeek is no Variable and you cannot use it like that. You need to run that Task before this Task and then use the output from it through {TASK(PrevTask|StdOut)}


Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
itellium
2015-02-24T11:55:18Z
Ok. I ran .Net code execute task first and worked in second task with {TASK(PrevTask|StdOut)}.
But I had defined in first task the parameter addweek=1. How I get result from {MATH(Add|Integer|{DATE(Week)}|-1|#00)} into parameter addweek?
Scroll to Top