May 12, 2005 at 3:09 pm
I wonder if any can help me. I want the default due date for a sales order to be today's date if it is entered before 2:00PM, if after, the default due date is the next business date. Any help will be appreciated. Thuan Pham
May 12, 2005 at 4:10 pm
if substring(convert(varchar(20), getdate(), 120), 12, 2) < 14
@due_date = getdate()
else
@due_date = dateadd(dd, 1, getdate()
May 12, 2005 at 7:15 pm
Do you want the time included in the default, or not? All of the posts, so far, include time.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 13, 2005 at 3:57 am
If you are using SQL2000 then you can use User defined functions. There you can write whatever logic you want. --Thanks Vilas
May 13, 2005 at 9:12 am
Just add ten hours to the time the order was placed. That will throw it into the next day.
declare @order_date datetime
declare @deliver_date datetime
set @deliver_date = dateadd(hh, 10, @order_date)
(Using a user defined function may be costly in terms of processing time unless you are processing one order at a time.)
May 13, 2005 at 11:28 am
Do you want the next date if it's a weekend day? Your original post said business date. If you add ten hours to the time of orders after 2 pm, that sets the date to the next contiguous date, but the time might be in the wee hours. Is that what you need?
May 13, 2005 at 2:08 pm
Thank you for all your help.
Thuan Pham
May 13, 2005 at 2:14 pm
declare @Date datetime
select @Date = getdate()--dateadd(hh, 0, getdate())
select
cast(Case
When datepart(hh, @Date) < 14
then convert(varchar(12), @Date, 101)
Else
Case datepart(dw, @Date + 1)
when 1 then convert(varchar(12), @Date+ 1, 101)
When 7 then convert(varchar(12), @Date+ 3, 101)
Else @Date
END
END as datetime)
Signature is NULL
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply