June 9, 2008 at 8:43 am
I would like to update a datetime data type column, lets call it fiscaldate based on a value from a different varchar column lets call it fiscal period.
so if the value in fiscalperiod = 200812
I would like to update fiscaldate for that row = 2008-12-01
if value in fiscalperiod = 200901
then fiscaldate = 2009-01-01
would someone show me how to accomplish this.. thanks
June 9, 2008 at 9:01 am
Like this:
UPDATE footable
SET fiscaldate = CAST(fiscalperiod+'01' as DateTime)
WHERE ...
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 9, 2008 at 11:36 am
thanks....
June 9, 2008 at 11:37 am
Glad I could help.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply