Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 convert timestamp to varchar

Author  Topic 

ntn104
Posting Yak Master

175 Posts

Posted - 2012-05-01 : 16:16:52
I joined to tables, 1st table indicate date is timestamp, and 2nd table format date=YYMM.

I want to convert timestamp to yymm format so I can join to 2nd table, but not sure how.

Sample date of 1st table: 2003-12-01-00.00.00.000000
Sample date of 2nd table: 0312
Thanks,

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-01 : 18:05:33
[code]CONVERT(VARCHAR(4),ColFromFirstTable,12)[/code]
Go to Top of Page

ntn104
Posting Yak Master

175 Posts

Posted - 2012-05-02 : 12:11:45
Thank you! it works like the way I want.

quote:
Originally posted by sunitabeck

CONVERT(VARCHAR(4),ColFromFirstTable,12)


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-02 : 19:57:19
quote:
Originally posted by ntn104

Thank you! it works like the way I want.

quote:
Originally posted by sunitabeck

CONVERT(VARCHAR(4),ColFromFirstTable,12)





you should be using proper datatype for storing dates. Otherwise you've to do lots of unwanted conversions to properly join data and use it for date manipulations

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -