Showing posts with label 8pm. Show all posts
Showing posts with label 8pm. Show all posts

Monday, March 19, 2012

how can check the time?

I have a stored procedure and I want to run a command based on time so if the time is after 8pm the charge the client US$ 10 otherwise US$ 8

Code Snippet


charge = case when datepart(hour, getdate())>=20 then 10 else 8 end

|||

That covers it up to midnight. Most likely you will also want to continue past midnight up to some early morning time.

If so, then something like this: (building on phdiwakar's suggestion) to charge $10 between 8 PM and 6 AM


Code Snippet

Charge = CASE
WHEN ( datepart( hour, getdate()) >= 20
OR datepart( hour, getdate()) <= 5
) THEN 10
ELSE 8
END

Wednesday, March 7, 2012

Hourly Scheduling

I have reports that I need to run every hour during the "scheduled" working
day.
Meaning between 8am and 8pm. The only way that I can see to do that is to
create one entry for each hour that I want it to run, meaning 12 scheduled
tasks for each report that I want to run in this manner ...
That could become a maintainence nightmare... Anyone got a better way to do
the same thing?
Thanks,
GaryCan't you create a SQL Server Agent Job Which occurs every 1 hour starting at
8AM and ending at 8PM?
HTH
"Gary Stewart" wrote:
> I have reports that I need to run every hour during the "scheduled" working
> day.
> Meaning between 8am and 8pm. The only way that I can see to do that is to
> create one entry for each hour that I want it to run, meaning 12 scheduled
> tasks for each report that I want to run in this manner ...
> That could become a maintainence nightmare... Anyone got a better way to do
> the same thing?
> Thanks,
> Gary
>
>|||You may create a subcscription for that report and choose hourly
schedule.
Gary Stewart wrote:
> I have reports that I need to run every hour during the "scheduled" working
> day.
> Meaning between 8am and 8pm. The only way that I can see to do that is to
> create one entry for each hour that I want it to run, meaning 12 scheduled
> tasks for each report that I want to run in this manner ...
> That could become a maintainence nightmare... Anyone got a better way to do
> the same thing?
> Thanks,
> Gary