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 2008 Forums
 Transact-SQL (2008)
 DB2 Date to SQL

Author  Topic 

Ratz03
Starting Member

27 Posts

Posted - 2015-02-25 : 07:39:48
Hi All,

I have a DB2 date accounting period with the format 11501 which is Jan 2015. I need to convert this date and compare it with the current date so as to pick accounting period 11501.

Please suggest how I can do this.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2015-02-25 : 08:53:10
SELECT 100 * DATEDIFF(YEAR, '19000101', GETDATE()) + MONTH(GETDATE()) AS AccountingPeriod;



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

Ratz03
Starting Member

27 Posts

Posted - 2015-02-25 : 10:18:27
thankyou works well.
Go to Top of Page
   

- Advertisement -