SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Changing Date value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masond
Constraint Violating Yak Guru

447 Posts

Posted - 12/06/2013 :  03:38:23  Show Profile  Reply with Quote
Hi All
I am hoping you can help me

Aim – Currently i have column “[LAST-STATUS-CHG]” in the following date format “042312” i need this date format to be changed into “23-04-12”.
Also i would like an additional column created called “Start of month” this column should look at “[LAST-STATUS-CHG]” and what ever the day is in the defauly it to 01

Current results
FDMSAccountNo ACCOUNT-STATUS LAST-STATUS-CHG
878000000884 16 042312
878000000885 13 011212
878000000886 12 100712



Desired results
FDMSAccountNo ACCOUNT-STATUS LAST-STATUS-CHG Start_of_month
878000000884 16 23-04-12 01-04-12
878000000885 13 01-12-12 01-12-12
878000000886 12 10-07-12 01-07-12



My query is
SELECT [FDMSAccountNo]
,[ACCOUNT-STATUS],
[LAST-STATUS-CHG]
FROM [FDMS].[dbo].[stg_LMPAB501]
where FDMSAccountNo = '878000000884'

looking forward to your help

Regards
D

Kristen
Test

United Kingdom
22403 Posts

Posted - 12/06/2013 :  03:45:35  Show Profile  Reply with Quote
SELECT [FDMSAccountNo]
,[ACCOUNT-STATUS],
[NEW-LAST-STATUS-CHG] = SUBSTRING([LAST-STATUS-CHG], 3, 2) + '-' + LEFT([LAST-STATUS-CHG], 2) + '-' + RIGHT([LAST-STATUS-CHG], 2)
FROM [FDMS].[dbo].[stg_LMPAB501]
where FDMSAccountNo = '878000000884'


Edited by - Kristen on 12/06/2013 03:47:10
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30217 Posts

Posted - 12/06/2013 :  04:44:05  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Hello and welcome back, Kristen!



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000