Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Converting part of a string to a date Expand / Collapse
Author
Message
Posted Wednesday, August 28, 2013 8:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Today @ 5:05 PM
Points: 4, Visits: 843
Hello everyone, I am very new to this forum but came across many good forum posts so I decided to join. My question is with regard to having an embedded date in a string and converting this to a date. I have a serial number like the following "GA0120100466" where the "GA" is not needed and really only the next six digits represent the date. So I can use the MID function and the LEFT function to extract "012010" without any trouble. Problem is I would like to convert this to a date so that I can calculate the age for example. So the date should be "01/20/10". Any help on this would be greatly appreciated. I also have some charting issues that I need to sort out at some point so if this is not the correct forum for inserting charts into SSRS reports let me know please.

Paul
Post #1489270
Posted Thursday, August 29, 2013 8:13 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 2:41 PM
Points: 214, Visits: 204
= FORMAT(DATESERIAL(LEFT(MID("GA0120100466",7),2),LEFT(MID("GA0120100466",3),2),LEFT(MID("GA0120100466",5),2)),"MM/dd/yy")

- Susan
Post #1489741
Posted Tuesday, September 3, 2013 12:53 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Today @ 5:05 PM
Points: 4, Visits: 843
Susan, thank you for your help. Worked like a charm!

Paul Bond
Post #1491067
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse