If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Computed Column "smalldatetime" from 3 separate columns?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-11-03, 17:05
odinsdream odinsdream is offline
Registered User
 
Join Date: Jun 2003
Posts: 10
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!
Reply With Quote
  #2 (permalink)  
Old 08-12-03, 08:57
dbadelphes dbadelphes is offline
Registered User
 
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))


Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On