User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 403,514 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,945 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 291 | Replies: 2
Reply
Join Date: Jul 2008
Posts: 8
Reputation: zenocide is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
zenocide zenocide is offline Offline
Newbie Poster

[Help] Procedure

  #1  
Jul 20th, 2008
Why is this script not working..


USE [KN_online]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[UPDATE_PREMIUM_SERVICE_USER_EXEC] 

AS 
 
DECLARE @d24 datetime

SET @d24 = DateAdd(hh,-24, GETDATE())
UPDATE PREMIUM_SERVICE SET nDays = nDays - 1 where Date > @d24


This is suppose to take 1 day of a users remaming days every 24 hours,, But its not working..

Please help.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2008
Posts: 8
Reputation: zenocide is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
zenocide zenocide is offline Offline
Newbie Poster

Re: [Help] Procedure

  #2  
Jul 20th, 2008
Ok got the first part done.

Just another little problem..

USE [KN_online]
GO
/****** Object:  StoredProcedure [dbo].[UPDATE_PREMIUM_SERVICE_USER_EXEC]    Script Date: 07/20/2008 17:28:50 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[UPDATE_PREMIUM_SERVICE_USER_EXEC] 

AS 
 
DECLARE @d24 smalldatetime

--- Below \/ = Check if date has been more than 24 hours,
--- If yes then deduct 1 day for Premium 
---             WORKS 100%

SET @d24 = DateAdd(hh,-24, GETDATE())

UPDATE PREMIUM_SERVICE_EXEC SET nDays = nDays - 1 where @d24 > Date


--- Below \/ = Check if Date has been more than 24 Hours, If yes start Begin
---              DONT WORK ATALL

SET @d24 = DateAdd(hh,-24, GETDATE())

if @d24 = getdate()
             
BEGIN

UPDATE PREMIUM_SERVICE_EXEC SET Date = getdate()

END
Reply With Quote  
Join Date: Jul 2008
Posts: 8
Reputation: zenocide is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
zenocide zenocide is offline Offline
Newbie Poster

Re: [Help] Procedure

  #3  
Jul 21st, 2008
I got this, but its updating the info every 15 mins, I need it to be every 1440 mins or 24 hours.

Can anyone help me?

DECLARE @d24 smalldatetime


SET @d24 = CONVERT(VARCHAR(15) , GETDATE(),102)
SET @d24 = DATEADD(HH,DATEPART(HH,dateadd(MI, 10, GETDATE())),@d24)

UPDATE PREMIUM_SERVICE SET nDays = nDays - 1 where @d24 > Date
UPDATE PREMIUM_SERVICE SET Date = getdate()where @d24 > Date
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 12:59 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC