counting days

  • The data type of (getdate()) is datetime which is inserted automatically when the data is entered by a visitor through a web site, for example 1/12/2006 20:35:03. (SQL Server 2000 connected as ODBC to web site)

     

    From that date, a number of days have been previously specified as part of the table design, say 8 for example.

     

    In another column on the same table and same row, at the same time, the number 0 appears, since not one day yet has elapsed, then the number 1 appears after one day (24 hours) has elapsed in real time, replaced by 2 for the second day , 3 etc.. as  the real time goes on, until the number 8 appears, at which the row as previously part of the design, is automatically deleted including the data.

     

    The data type is mainly nvarchar and image is optional.

     

    How to go in trying to achieve this in a simple way  ?

    Thanks. Yves

  • It's probably a computed column.

    In Enterprise Manager, find the table, go to Design Table, and check out the formula property for the column in question.

  • Thanks for the lead.

    Yves.

  • Since the row is automatically deleted after 8 days, I'm thinking it's a combination of a computed column and trigger.... or the trigger just has an update/delete.

    I'm thinking that deleting the data is a bad idea... leaves no trace... the data should be archived (moved to a different table) instead.

    The computed column would have something like this in it...

    DATEDIFF(dd,datecolumn,GETDATE())

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Actually... you've posted this nearly identical question 3 times on this forum and a couple of times on other forums.  Folks have told you how to do this many ways... why are you still having problems with this?  Instead of just posting the same question over and over, please identify what problem you are having with solutions given... haven't you tried any of them?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • The topic question had 2 components on the start.There is more than one way in putting a request which may be understood differently by different persons.There is also more than one way of doing nearly the same thing.There is no problems about it.The 'problem' has been identified and is being worked at the present with the kind help of the forums and it is very appreciated.

    Thank you for your concern.

    Regards,Yves.

     

  • Whatever... it's still called a cross-post and will tick off some of the people trying to help because the problem is scattered across 3 posts instead of on a single post where we can see all of the answers that have been suggested... keeps us from duplicated work.  We do do this for free, ya know?

    Anyway, are you all set or do you need help with something else on this problem?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Ideally one topic one answer ! ha! would be to wonderful !... Life is not like this.I do not believe there is a duplicated work in this matter, neither anybody is going to be 'ticked off ' of anything .

    Regards,Yves.

     

  • Yves the point that Jeff is trying to make is that when someone cross-posts, you dilute the help.  Imagine someone spending 1 hour working on your problem and then finding out it was already answered twice in other threads.  This is where the people can really get pissed off.  I'm pretty sure it didn't happen in this case but it's something I think anyone should keep in mind.

  • Ninja's RGR' us , I note your point of cross-posts resulting in diluting the help.Answers were different although some similarities from different persons.The topic has been written in three way as to be more specific to the request of some answers and it has ended happily few days ago.Cross posts is always in mind in forums.

    Regards,Yves.

  • I'm not trying to say that this was what happenned.  I was just clarifying Jeff's pointof you which I totally agree with (already lost the count of days I lost double answering posts).

     

    However I'm glad to see that we are all on the same page here.

     

    Merry xmas and happy new year!

  • No assumptions on that matter which was closed.

    Regards and happy new year !

  • Heh... Good luck, Yves.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply