Page 1 of 1

find day of week

Posted: Tue Sep 10, 2013 6:32 am
by mallikharjuna
Hi,

I have 2 jobs in sequence ,first job will execute daily and second job should execite if it is Saturday, how to implement in sequence? any built in function will help?

Thanks
Malli

Posted: Tue Sep 10, 2013 6:43 am
by ArndW
The function

Code: Select all

OCONV(@DATE,'DW')
will return a number, 1-7 for Mon through Sun. Thus a query on this having a value = 6 will mean you are running on a Saturday.

Posted: Tue Sep 10, 2013 10:13 am
by mallikharjuna
Thanks ArndW.I have used this function,working fine.I think the return code 1-7 for Sunday through Saturday, then Saturday=7.Please correct me if i am wrong.

Posted: Tue Sep 10, 2013 11:03 am
by ArndW
Simple to test, write a datastage server function. I just did and it considers today, Tuesday, to be a 3. Thus in our installation Sunday is day 1. I had forgotten that this value can change. According to the UV/BASIC docs:
Requests only the day number within the week (1 through 7, where Sunday is 7). If NLS locales are enabled, uses the DAYS field in the NLS.LC.TIME file, where Sunday is 1.

Posted: Tue Sep 10, 2013 4:12 pm
by ray.wurlod
Or you could use Oconv(@DATE, "DWA") to get the day name, or Oconv(@DATE, "DWB") to get the abbreviated day name. Then the numeric value does not really come into play.

Posted: Wed Sep 11, 2013 3:38 am
by ArndW
Both the day name and the abbreviated day name are dependent upon the NLS settings just as the "DW" is, so it is down to a matter of personal choice.