changing dates on one instance/database

  • i have several instances, applications running in a machine. Is there a way to change the date in one instance or database alone, so that I can frequently change the dates and test it. Thanks in advance.

  • Interesting question.

    Not that I am aware of, maybe define a function which returns the date/time with your date/time offset applied and use it in the place of GetDate().

  • Thanks. Do you think I can create a function called getdate(), which will overrule the sytemwide getdate() function. Or will my instance crash, when I compile it?

  • It is not working. I created a function, but i cannot do select getdate() on it. This function needs to be invoked like a stored procedure. Any other way ? Just dont want to touch the OS date.

  • Try a view

    Create view Test as Select DateAdd(hh,2,GetDate()) as TheDate

    I have used 2 hours as an offset value.

  • Not the best, but seems to be working.

    CREATE VIEW Test as Select DateAdd(hh,2,GetDate()) as TheDate

    GO

    CREATE FUNCTION TestDate()

    Returns @TheTable TABLE ([GETDATE] DateTime) as

    BEGIN

    Insert @TheTable

    Select TheDate From Test

    RETURN

    END

    GO

    CREATE FUNCTION TestDateII()

    Returns DateTime

    BEGIN

    RETURN (Select [GetDate] from dbo.TestDate())

    END

    GO

    Select dbo.TestDateII()

    GO

    Suspect the overhead will make it a bit slow, maybe OK for testing!

Viewing 6 posts - 1 through 5 (of 5 total)

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