SQL figuring out days remaining based on days interval (using SQL Server 2005)? -


I have a table that represents the user's membership on our system. I have two tables representing membership for one account and the other shows the type of membership. The subscription table relates to the membership type table related to the subscription type field in the subscription type table. I need to understand the remaining days of that account. This is my example:

Users were signed up on January 1, 2010 and their tenure is 30 days. Based on today's date (January 25, 2010), they will have 6 days left.

I need help in designing SQL so far in my stored methodology:

  @Assignment IDId ady @term int declared rest int set @term = (SELECT subscriptionTerm FROM dbo. Subscription type where dbo.SubscriptionTypes.SubscriptionTypesID = @ SubscriptionTypesID)  

Now I have to find out what to do with the remaining questions, or if I somehow I can do a SQL statement, so I can get a different position Vshykta not. / P>

Update:

Here's what I've got with your help, but still I want a more exaggerated way to pump word fields in the query field:

Select
  (update date (meet day, meet (), DATEADD (day, 30, '01 / 01/2010 ')))  

2.0 ;)

Sometimes the answer is right in front of me and I can not even see it. I hope to understand the problems and make them more complicated for whom they should be, thanks to those who helped! Here is the code:

  Select (DETAILS (day, meet (), DATEAD (day, membership duration, deb. Subscription membership day))) Membership Join INNER dbo.SubscriptionTypes ON (Dbo.ubsubscriptions.ubscriptionTypeID = dbo.SubscriptionTypes.SubscriptionTypesID) WHERE dbo.Subscriptions.userID = 129  

You can use the Datadiff functionality from SQL:

You can also solve it:

You can find out more in the same MSDN page, just use the search box and type "DataDate" ( date, date)

/ P>

Best wishes for the rest of your time;)


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -