Pyrite | Level 9

## Adding one day to DATETIME date

Hi Community,

I have a dataset where I need only to change the red vs2 date to a day later  (in below the first vs2 date really should be 24APR2015:00:06:00) and the last vs2 date really should be 22NOV2017:00:04:00, while the other dates should remain the same.

How should I handle situation like this?  Thanks as always

 vs1 vs2 23APR2015:23:51:00 23APR2015:00:06:00 05MAY2015:13:00:00 05MAY2015:12:59:00 06JUN2015:18:52:00 06JUN2015:18:52:00 23AUG2015:23:32:00 23AUG2015:23:30:00 10SEP2015:20:39:00 10SEP2015:20:32:00 23SEP2015:21:48:00 23SEP2015:21:44:00 07DEC2015:12:45:00 07DEC2015:12:27:00 21NOV2017:23:40:00 21NOV2017:00:04:00
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Adding one day to DATETIME date

Do you mean you want to make the change if vs2 is more than an hour before vs1?

``if vs1 - vs2 > 3600 then vs2 = intnx('dtday',vs2,1,'s');``
6 REPLIES 6
Super User

## Re: Adding one day to DATETIME date

Is there logic for why those two need to change? Or do you just want to test for any value on those dates?

Pyrite | Level 9

## Re: Adding one day to DATETIME date

@Tom

Thank you for inquiring, those values in red are the correct values, basically vs2 should start a few minutes after vs1, so the situation is vs1 and vs2 just happens to cross the midnight, while the other values have issues which I don't want to program to change, they need further investigation

Super User

## Re: Adding one day to DATETIME date

How do you identify the dates that need to be changed?

The function for calculation of intervals is intnx(). Use "dtday" as interval.

Pyrite | Level 9

## Re: Adding one day to DATETIME date

@Kurt_Bremser

Thanks for inquiring. I plan to use

vs1_2 = INTCK('hour',vs2,vs1);

vs1_2  = 23;

to indentify those values across the midnight.

Super User

## Re: Adding one day to DATETIME date

Do you mean you want to make the change if vs2 is more than an hour before vs1?

``if vs1 - vs2 > 3600 then vs2 = intnx('dtday',vs2,1,'s');``
Pyrite | Level 9

## Re: Adding one day to DATETIME date

@Kurt_Bremser

I should add 24 hours to vs2 to bring vs2 one day ahead of its current status, that is my plan, just like to consult the experts here

Discussion stats
• 6 replies
• 5827 views
• 0 likes
• 3 in conversation