Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Grab Date/Time From SQL Server (2000)

    I've got an Access 2000 frontend linked to an SQL Server database. There are times when I want to insert the current date and time into a record, but I want the current date and time from the SQL Server and not from the user's local computer. Is there an easy way to do this?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Grab Date/Time From SQL Server (2000)

    You'd have to do it from SQL Server, I think. Depending on what you're trying to do, a trigger on the table might work. Otherwise, a stored procedure should do it.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Feb 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Grab Date/Time From SQL Server (2000)

    Charlotte,

    Thanks for the reply. I was looking in the direction of stored procedures myself, but I'm not overly familiar with them. The problem I see with use one is that I have variable information that would need to be passed to the SP. Can that be done with Access VBA?

    Lee

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Grab Date/Time From SQL Server (2000)

    Sure, if you set the sp up to accept parameters. If you rummage around in this forum and VB/VBA/.Net, you'll undoubtedly find some examples of passing parameters into SQL Server.
    Charlotte

  5. #5
    New Lounger
    Join Date
    Feb 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Grab Date/Time From SQL Server (2000)

    Charlotte,

    Thanks for the input! It got the ideas flowing and I was able to figure out the answer. :-)

    Lee

  6. #6
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Grab Date/Time From SQL Server (2000)

    We routinely use the SQL GetDate function to get the server Date and Time for tracking changes, and we all use the function suser_name (not sure the name is totally correct) in SQL Server 2000 to capture who made the change. These can simply be set as default values if you are capturing who add the record intitially. Changes will need to be done typically with triggers - you can use Sprocs but they require an Access interface and are a little more cumberson. Triggers happen automatically with no Access involvement. They also apply to things you do at the SQL level, but they are a pain to design and debug. Hope this sheds a bit of added light on the subject.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •