Solved

How do I convert this combination into a specific date

Posted on 2011-02-18
4
268 Views
Last Modified: 2012-05-11
I have a fiscal years (ranging from 2005 - 2011) and various dates as of 6/30/XX.  I need to change the 6/30/XX into the proper year based on the fiscal year.  If the fiscal year is 2005 I need the date to be 6/30/04.  If the fiscal year is 2006 I need the date to be 6/30/05.   I can't quite figure out how to do this
0
Comment
Question by:cindyfiller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 250 total points
ID: 34929976
Does the following work for you?

select CAST(CAST(2005 - 1 AS varchar(10)) + '-06-30' AS DATETIME)

0
 
LVL 26

Expert Comment

by:tigin44
ID: 34929978
try this
SELECT dateColumn, DATEADD(year,  -1 * (YEAR(dateColumn) - fiscalYearColumn),  dateColumn)  
FROM yourTable

Open in new window

0
 
LVL 40

Expert Comment

by:lcohan
ID: 34929988
I guess the CAST/CONVERT SQL functions is what you need:

http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 34930073
I am sure I understand the question but wonder if something like this will work ?

declare @yy AS INT
declare @date as dateTime

-- get the current fiscal year - 1
Set @yy = (YEAR(GETDATE()) % 100) - 1

-- set your date
Set @date = '6/30/' + CAST (@yy AS VARCHAR (100))

Print @date
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question