SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Converting part of a string to a date


Converting part of a string to a date

Author
Message
pabond
pabond
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 870
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
sribe
sribe
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 260
= FORMAT(DATESERIAL(LEFT(MID("GA0120100466",7),2),LEFT(MID("GA0120100466",3),2),LEFT(MID("GA0120100466",5),2)),"MM/dd/yy")

- Susan
pabond
pabond
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 870
Susan, thank you for your help. Worked like a charm!

Paul Bond
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search