date Transformation using DTS

  • for transforming date such as 01-jan-03

    into month,day ,year ,quarter..

    when i use the follwing code..

    when i execute the query it shows me the correct results except for the month number..

    which remains same for all rows however the month name is shown properly..

    but in the meanwhile..when i use it to create a target table using DTS..it places NULL..in the target table in the columns..month name and month number..

    what should i do about it..

    one more problem i want quarter to be shown in the form..

    Q1,Q2 and so on..

    what should i do about this ..i am using the following code 4 this

    SELECT DATEPART(yyyy, INDEX_DAT) AS TheYear,

    DATEPART(qq, INDEX_DAT) AS TheQuarter,

    DATEPART(mm, INDEX_DAT) AS monthnumber,

    DATENAME(month, GETDATE()) AS 'Month Name',

    DATEPART(dd, INDEX_DAT) AS TheDay

    FROM [lse101index]

  • I see nothing wrong with monthnumber but monthname will always be the same because you are using GETDATE()

    use

    DATENAME(month, INDEX_DAT) AS 'Month Name'

    for month name

    and

    'Q'+CAST(DATEPART(qq, INDEX_DAT) as varchar) AS TheQuarter

    to get Q with the qtr number

    Far away is close at hand in the images of elsewhere.
    Anon.

  • To get the quarter to return as Q1, Q2, and so on, use the following for the quarter column:

    'Q' + cast(DATEPART(qq, INDEX_DAT) as varchar(2)) AS TheQuarter

    Happy coding,

    Diane

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

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