Getting a start time with a query

  • I have the following query:

    select MAX(payrolldate) AS [payrolldate],

    dateadd(dd, ((datediff(dd, '17530107', MAX(payrolldate))/7)*7)+7, '17530107') AS [Sunday]

    from dbo.payroll

    where payrollran = 'no'

    and I'm trying to get both a start date of the next available Sunday and also the start time of 12:00:00. I am able to get the next start date but not the time. Can anyone please assist?

    Thank you

    Doug

  • Does this do what you want?

    select

    MAX(payrolldate) AS [payrolldate],

    dateadd(dd,

    ((datediff(dd, '17530107', MAX(payrolldate))/7)*7)+7,

    '17530107 12:00:00') AS [Sunday]

    from dbo.payroll

    where payrollran = 'no'

Viewing 2 posts - 1 through 1 (of 1 total)

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