10-15-2014 04:26 PM
i'd like to increase a variable (payday) + 1 while it isn't a working day
how can i do something like that, using while and sql?
create table new_payday as select
(while payday in ((select holiday from holiday_table),weekday(1),weekday(7)) then payday+1) as payday
10-15-2014 04:46 PM
Not sure, but I think you are trying something like this
create table new_payday as
case when weekday(datepart(payday)) in (1,7) then payday+1 else payday end as payday
10-15-2014 06:21 PM
If it was Saturday that would make the payday Sunday so that logic doesn't make sense for most businesses I know....
Look up the intnx function with the weekday option.
You can also create custom intervals to include your holidays, there's a few posts on here that cover how to do that.
10-15-2014 11:33 PM
I think you're looking for where instead. I'm not familiar with while in SQL though it's getting rusty...
However the intervalds option methodology with customized dataset would render that requirement for this question moot.