1 Reply Latest reply: May 15, 2014 9:55 AM by Gareth Horton RSS

    DateAdd Function

    javacafe _

      Hi all;

      I wonder if there's any way we could get a date value as DateAdd function in .NET.

      My problem is: I have a "Work_Date" field in format "MM/DD/YYYY" and now I want to get the date of Sunday followed by that "Work_Date" and insert into "Weekend_Date" field.

       

      Ex: Work_Date     Weekend_Date

          08/31/2006    09/03/2006

          (Thursday)    (Sunday)

       

      something like this:

      If(weekday(Work_Date) <> 1)

         Weekend_Date = DateAdd(Work_Date, 8 - weekday(Work_Date))

      else

         Weekend_Date = Work_Date

       

      Thank you in advance

        • DateAdd Function
          Gareth Horton

          Hi,

           

          This should work fine.

           

          Just create a calculated field called Weekend_Date and use the following formula.

           

          You can add and subtract days by using plus and minus, so you can return tomorrow's date by using Today()+1 for example.

           

          [font="courier"]If(weekday(Work_Date) <> 1,(Work_Date+(8-weekday(Work_Date))),Work_Date)  /font[/quote]Gareth

           

          Originally posted by javacafe:

          Hi all;

          I wonder if there's any way we could get a date value as DateAdd function in .NET.

          My problem is: I have a "Work_Date" field in format "MM/DD/YYYY" and now I want to get the date of Sunday followed by that "Work_Date" and insert into "Weekend_Date" field.

           

          Ex: Work_Date     Weekend_Date

              08/31/2006    09/03/2006

              (Thursday)    (Sunday)

           

          something like this:

          If(weekday(Work_Date) <> 1)

             Weekend_Date = DateAdd(Work_Date, 8 - weekday(Work_Date))

          else

             Weekend_Date = Work_Date

           

          Thank you in advance /b[/quote]