0

Hello i've been working on how to get yesterday date in DataStage?

CurrentDate()-1

When i compile the job, it gave me an error. So how should i do to get the yesterday date? btw that code i'm doing it in the Transformer stage

PiPio
  • 89
  • 1
  • 3
  • 11

3 Answers3

2

Assuming you are using the parallel engine in DataStage - this could be a solution

DateOffsetByComponents

DateOffsetByComponents(CurrentDate(), 0, 0, -1)

As the last parameter is the day part and -1 would substract a day

MichaelTiefenbacher
  • 3,805
  • 2
  • 11
  • 17
1

Convert the date into a date type, then you can add or subtract days.

You can use IConv to convert a string into a datastage internal date format. Then you can perform addition/subtraction on the date. Then use OConv to convert the variable back to string format.

If this is done in a transformer stage, you need to do this all in one statement:

OConv(Iconv(VDate ,"D/YMD[4,2,2]") - 1), "D/YMD[4,2,2]")

Hope this helps.

Devanshi Mishra
  • 487
  • 5
  • 15
  • I'm a total starter (newbs) here, and what does that 4,2,2 means? – PiPio Nov 27 '19 at 08:08
  • 1
    The purpose of ICONV for dates is to convert them into a single internal format ,irrespective of the external format. ICONV is extremely flexible. If the component ordering of the external date is the same as that of your locale, then the only specification needed is "D". If the component ordering in the external date is different from that of your locale, you need only specify the component markers. Irrespective of the actual delimiters in the external format, ICONV will cope. You can specify any of the following as per your need - D-YMD[4,2,2] D-YMD[2,2,2] D/MDY[2,2,4] etc – Devanshi Mishra Nov 27 '19 at 08:56
  • 1
    You can read more about it here - https://www.intl-spectrum.com/Article/r483/MultiValue_OCONVICONV_in__NET__Date_Conversion – Devanshi Mishra Nov 27 '19 at 10:00
0

In a parallel Transformer stage, I'd use DateFromDaysSince() function. Use current date function as the base, and -1 as the offset value.

Ray Wurlod
  • 831
  • 1
  • 4
  • 3