Forum Replies Created

Viewing 15 posts - 7,831 through 7,845 (of 8,731 total)

  • RE: Convert Varchar to Date??

    What's wrong with a simple CAST or CONVERT?

    SELECT CONVERT( datetime, 'Jul 24 2013 8:05AM')

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Change sub query variable based upon sub query

    I'm not sure I'm getting this correct, but based on your description, this is my guess.

    There are some errors on the code, I changed to what seemed correct.

    --Look for these...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: assign Null value to a column

    You could use NULLIF(DeptCount, 0)

    EDIT: Add reference http://msdn.microsoft.com/en-us/library/ms177562%28v=sql.90%29.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SQL PIVOT problem

    Check out the following links

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs[/url]

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Find the last 6 Tuesdays or Wed or Whatever day.

    What about a simple DATEADD(wk, -1, GETDATE()) and change the value to bee substracted?

    Or use DATEADD(wk, -6, GETDATE()) AND DATENAME(dw, date_needed) = 'Tuesday'?

    It's an idea. You could also use DATEPART.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Function to return the fiscal month from a date. Fiscal year begins in October

    No, it won't. Unless they add 3 new months to the calendar.:-D

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: create table valued function

    You don't have any variables in your code.

    You can check the CREATE FUNCTION syntax in here http://msdn.microsoft.com/es-es/library/ms186755%28v=sql.90%29.aspx

    CREATE FUNCTION dbo.Example_function_name

    (

    @Parameter1 int

    )

    RETURNS TABLE

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Add one MilliSecond to each row

    Thank you for the reference Lowell, I knew I had read it, but I wasn't sure where to start looking for it again.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Add one MilliSecond to each row

    First of all, you can't add a milisecond to a datetime, you need to use datetime2.

    Here's an example, if you remove the CAST, you'll see what I mean.

    SELECT TOP (500)...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Getting DateOfBirth of youngest person.

    Let's get some coffee before we answer in the morning 🙂

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How to write a codition based on min rank

    I'm glad I could help.

    Thank you for the feedback.;-)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Getting DateOfBirth of youngest person.

    The problem with MIN(DateFoBirth) is that is getting the oldest person, not the youngest. :hehe:

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Sum the Attendance Hours by Category and then Group by 'Week of'

    This works for me.

    SELECT ID,

    CASE WHEN Category IN( 'Art', 'PE') THEN 'Non Educational' ELSE Category END Category,

    DATEADD( dd, -1, DATEADD(wk, DATEDIFF(wk,0,Date), 0)) Week,

    SUM(Hours) Total_Hours

    FROM Attendance

    GROUP BY ID,

    CASE WHEN Category...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Sum the Attendance Hours by Category and then Group by 'Week of'

    I misread a part of your original post and became more clear now.

    You could use DATEADD(wk, DATEDIFF(wk,0,Date), 0) to get the first day of the week and be able to...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Getting DateOfBirth of youngest person.

    Eric M Russell (7/25/2013)


    Luis Cazares (7/25/2013)


    How about this?

    SELECT TOP 1 *

    FROM MyTable

    ORDER BY DateOfBirth DESC

    We also can't assume that DateOfBirth isn't nullable.

    SELECT TOP 1 *

    FROM MyTable

    WHERE DateOfBirth is not null

    ORDER...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 7,831 through 7,845 (of 8,731 total)