Reformating Date_Stamp variable

 8 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
April
Basic Member
Posts: 15
Basic Member
    I am trying to reformat the Date_Stamp value to either AGS or DME so I can use it in a branch.  This is what I have in the Assign node, but it doesn't like it:  stamp=  getDateAGS(SQLQuery240_DATE_STAMP).    I have tried several functions but I can't seem to get it.  My ultimate goal is compare it again a date (either DME or AGS) for 7 days ago. 
    Thanks for the help in advance.
    April
    Gary Davies
    Veteran Member
    Posts: 248
    Veteran Member
      The getDateAGS function expects a parameter in Javascript date format, which basically is stored as number of seconds since a date in the past, that start date can varying depending on the and can vary depending box. It also requires the result be a string.

      If the SQL query date time is not in javascript format you will have to create a Date variable, parse the DATE_STAMP and populate the new variable with the Day Month Year Hours Minutes and Seconds (using javascript Date functions) and use that variable in your function call. If you have to parse to get the values I would say just create a new string and don't even bother with the getDateAGS call.

      There is a function pfDate that will convert a date in either MM/DD/YY or YYYYMMDD format to javascript date. But that seems redundant if you have to parse anyway as well.
      Derek Czarny
      Veteran Member
      Posts: 63
      Veteran Member
        I believe I was having the same problem that you are describing.  I had a query that returned a date field (put date into variable) and I was trying to compare that date in a branch to a variable, but it wasn't working properly.  I added the function date.parse() around my dates and it seem to work. 

        Date.parse(vLastPurchaseDate) >= Date.parse(vDisableVendor)

        April
        Basic Member
        Posts: 15
        Basic Member
          I tried entering in the Date.parse( ) but the value I get in return is NaN. What is that?
          David Williams
          Veteran Member
          Posts: 1127
          Veteran Member
            Nan is "Not a Number." Query or AGS values usually get returned as "text" value fields, even if they are a number or date. What do you want your Branch to do? And when will you compare this date to another date 7 days ago?
            David Williams
            April
            Basic Member
            Posts: 15
            Basic Member
              I want the branch to pass the records if less than 7 days ago, otherwise kill the record (send to end).
              My DATE_STAMP value is 2009-02-25 00:00:00.0
              The variables I created for 7 days ago are: Tue Jun 09 2009 15:09:22 GMT-0400 (GMT-04:00) and 20090609
              and 06/09/2009. Once I get variables that I can compare, I planned on (in the branch) to use something like date_stamp variable >= 7days ago variable.
              Thanks, April
              Derek Czarny
              Veteran Member
              Posts: 63
              Veteran Member

                On your Start Node, create 2 variables, both Date variables.  Set the first variable to AddDay(today(),-7) and the second variable to today().  Then create your query in your query node that returns the date field you want to compare your variables to.  Write the date field from your query to a 3rd date variable in an assign node.  Then in your branch use the Date.parse() around your variables to write your compare statement.  Date.parse(variable1) >= Date.parse(variable3) && Date.parse(variable2) <= Date.parse(variable3)

                Something like that.

                David Williams
                Veteran Member
                Posts: 1127
                Veteran Member
                  If the date parse doesn't work, try this.
                  Add a date variable: dt1=AddDay(today(),-7)
                  Add a date variable: dt2=today()
                  Add an integer variable: dtdf=0
                  After your AGS or DME call use an Assign to reassign your 2nd variable to your call's date
                  Within that same Assign, assign the integer variable this expression dtdf=DateDiff(dt1,dt2)
                  Use the dtdf variable in your Branch
                  David Williams
                  April
                  Basic Member
                  Posts: 15
                  Basic Member
                    Thank you so much for all your help.  I got this working.  April