Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Posts
    10

    Unanswered: Computed Column "smalldatetime" from 3 separate columns?

    I am currently storing:

    ReportMonth As tinyint
    ReportDay As tinyint
    ReportYear As tinyint

    in my table. Client software requires that I have a "smalldatetime" column, which contains the date. I'd like to base it off the current 3 columns I have (seeing as how I have months worth of data)

    I tried the following formula, as well as variations thereof:

    (convert(smalldatetime, ReportYear + "-" + ReportMonth + "-" + ReportYear))

    What is the correct formula for performing the calculation? I can't seem to get it.

    Thanks for your help!

  2. #2
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: Computed Column "smalldatetime" from 3 separate columns?

    You'd rather try:

    convert(smalldatetime, convert(nvarchar,@ReportMonth) + N"-" + convert(nvarchar, @ReportDay + N"-" + convert(nvarchar,@ReportYear))


    Originally posted by odinsdream
    I am currently storing:

    ReportMonth As tinyint
    ReportDay As tinyint
    ReportYear As tinyint

    in my table. Client software requires that I have a "smalldatetime" column, which contains the date. I'd like to base it off the current 3 columns I have (seeing as how I have months worth of data)

    I tried the following formula, as well as variations thereof:

    (convert(smalldatetime, ReportYear + "-" + ReportMonth + "-" + ReportYear))

    What is the correct formula for performing the calculation? I can't seem to get it.

    Thanks for your help!
    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •