get dates

Posted on 2012-09-19
Last Modified: 2012-09-19
what's the best way to meet the following?

end date is now - 6hrs
start date is end date - 48hrs

Does this seem right?

declare @startDate as datetime
declare @endDate as datetime

Set @endDate = dateadd(hh,-6,getdate())
Set @startDate =  dateadd(hh,-48,@endDate)
Question by:fwstealer
    LVL 21

    Accepted Solution

    If this isn't a trick question then yes, that seems fine.

    Author Comment

    i wish - no I just sux at sql :-)

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now