Forum Replies Created

Viewing 10 posts - 346 through 355 (of 355 total)

  • RE: Determining the Nearest Record to a Given Location

    I've been thinking about this problem over the weekend, and I reckon I've come up with an extension of the method proposed by rbarryyoung that reliably returns the nearest point...

  • RE: Determining the Nearest Record to a Given Location

    Good catch. But that leaves me wondering how it converts the results from Great Circle Radians to Miles?

    It's not converting from great circle radians to miles - it doesn't...

  • RE: Determining the Nearest Record to a Given Location

    Well, I snatched them from a post at the site that Chris Morris linked too (had to fix a bug in it though), which had no real explanation of it,...

  • RE: Function that finds Sundays

    Try this:

    -- based on 1/1/1900 = 0 is a Monday

    PRINT GETDATE()

    PRINT 'Next occurance of Monday: '

    PRINT DATEADD(day, DATEDIFF(day,0,GETDATE()-1)/7*7+7, 0) -- use 1/1/1900 = 0 is a Monday

    PRINT 'Next occurance of...

  • RE: Function that finds Sundays

    SELECT DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '19000101') AS followingMonday,

    DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE())...

  • RE: Function that finds Sundays

    SELECT DATEADD(wk,DATEDIFF(wk, 0, getdate()), 6)

    Yes, this works well for Sundays, but it is not as straightforward as you would hope to generalise it to work for other days of the...

  • RE: Function that finds Sundays

    Or more generally, if @weekday represents the weekday that you want to retrieve, where Monday = 1, Tuesday = 2, ..., Sunday = 7, then the following expressions will do...

  • RE: Function that finds Sundays

    The following returns the date that is the next Sunday. If today is Sunday, it returns today.

    SELECT DATEADD(day, (15 - DATEPART(dw, GETDATE()) - @@DATEFIRST) % 7, GETDATE())

    The following returns the...

  • RE: Function that finds Sundays

    select getdate() + 7 - Datepart(dw, getdate())

    This only works if @@DATEFIRST = 1 (Monday)

    An expression that returns the date of the Sunday in the current week regardless of...

  • RE: Stock Ledger - Without cursor

    This is one of those situations where using a cursor is the more natural approach and will probably be more efficient than any possible single query approach.

    The following query that...

Viewing 10 posts - 346 through 355 (of 355 total)