문제

I would need to add to a date format variable 7 days.

The variable is creation_date and is like 01JAN14:00:08:04.

I wrote this in a data step

sevendays_after=CREATION_DATE+ 7 * 24 * 60 * 60;

but the result is like 1.70476E9

and I need it like 08JAN14:00:08:04.

Also I would need to keep only the yymmdd or ddmmmyy and I don't know how to do this either.

Thanks!

도움이 되었습니까?

해결책

You need to apply a format to your data.

format sevendays_after DATETIME17.;

Or DTMONYY. or similar.

You should use INTNX, in any event.

sevendays_after = intnx('DTDAY',creation_date,7);

That way you don't have to do the math.

If you just want the date, and would like to discard the time information entirely, you can use datepart to do that (although that should only be done if the time part is useless, such as a date-stamp that is forced into datetime by SQL Server).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top