Forum Replies Created

Viewing 15 posts - 256 through 270 (of 355 total)

  • RE: Syntax error converting datetime from character string

    What's the data type of the following columns?

    If they are character fields, how are the date strings formatted?

    BW1.dbo.qryIntermediate_CIS_BrentEvents.EV_DATE

    BW1.dbo.qryIntermediate_CIS_BrentEvents.REF_DATE

    Also the following isn't a reliable way of calculating a person's age -...

  • RE: a<>b OR not(a=b)

    I think that you could argue with your "senior programmer" that "a <> b" is more readable and maintanable and is thus the preferable method. A "senior programmer" should understand...

  • RE: How to get day of a specific week

    How about this.

    By setting @firstWeekday, the code can be made to work for any day being the first day of the week, or you can set it to @@DATEFIRST for...

  • RE: How to get day of a specific week

    How are you defining the start and end of a week and how are you defining week numbers?

    For instance, if your week runs from Sunday to Saturday, if the 1st...

  • RE: select statement

    Doubled single quotes rather than double quotes.

    [font="Courier New"]EXECUTE('Select ''A'' as [Test],* From myTable')[/font]

  • RE: Help Needed for Update Query

    You could set the MaximumValue of the top ranked entry in the TblMasterData table to NULL and use the following amended query.

    UPDATE C SET C.rank = M.ReputationValue

    FROM TblComputedData C...

  • RE: Help Needed for Update Query

    UPDATE C

    SET C.rank = M.reputationvalue

    FROM TblComputedData C INNER JOIN TblFeedbackData F

    ON c.userId = F.UserId

    INNER JOIN TblMasterData m

    ON F.Score BETWEEN m.MinimumValue and M.MaximumValue

    WHERE isProcessed =1

    There's a potential problem...

  • RE: query to find last date of a year

    How about this

    /* If you are starting from a datetime */

    DECLARE @date datetime

    SELECT @date = '2009-01-01'

    SELECT DATEADD(year, DATEDIFF(year, -1, @date), -1)

    /* or */

    SELECT DATEADD(year, DATEPART(year, @date) - 1899, -1)

    /* or...

  • RE: How to find Week start date and Week end date

    The following works regardless of the value of @@DATEFIRST

    DECLARE @today datetime

    DECLARE @weekday int

    DECLARE @startInterval datetime

    DECLARE @endInterval datetime

    SELECT

    @today = DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0),

    @weekday = DATEDIFF(day, 0, @today) % 7,

    @startInterval...

  • RE: Left outer join

    Does this work?

    It's untested.

    SELECT

    T.bol_no,

    T.rev_no,

    T.trailer_id,

    C.comm_code,

    DC.prod_storage_id,

    C.comm_um,

    DCO.quantity,

    C.end_scale_wt,

    C.quantity,

    extended_weight = (

    SELECT multiplier * DCO.quantity

    FROM BDS_COMMODITY_UM_CONVERT BCUM

    WHERE (BCUM.comm_code =...

  • RE: Determining the Nearest Record to a Given Location

    One quick question.... What's the logic behind the bounding box?

    Where Longitude between @Longitude-.1 and @Longitude+.1

    And Latitude between @Latitude-.1 and @Latitude+.1

    Is that...

  • RE: Converting to Month-Year Format

    You were previously given sufficient advice that should have enabled you to amend your own query, but I've done it for you here, plus tidied up a few details. I'm...

  • RE: CTE Recursion Limitation

    There are several other ways of splitting a delimited string, some of which are more efficient than using recursive CTEs.

    You could use a Tally table, convert to an XML string...

  • RE: Days and Time

    The use of Julian date to refer to the day-of-year (ordinal date) is usually considered to be incorrect...

    Quite right - apologies for my sloppy terminology.

  • RE: Days and Time

    Given that January 1st is the first ordinal day of a year, the example TSQL scripts above are 1 day out.

    If the date and time fields are stored as integers...

Viewing 15 posts - 256 through 270 (of 355 total)