Hi all,
I have a number like so 778625 and want to make
this a more meaningful date (UK) so how difficult is it to
add two digits in this case 19 to the front of this number?
Many thanks
SamThis is a date? I'm not sure I understand how 1977 is any more meaningful
than 77, when the rest of the number is 8625. But okay, I suppose you could
do this:
DECLARE @.i INT
SET @.i = 778625
SELECT '19'+CAST(@.i AS VARCHAR)
And if you have to do it conditionally, say if the first two digits are less
than 30 you assume it's 20xx, then
DECLARE @.i INT, @.ivc VARCHAR(12)
SELECT @.i = 778625, @.ivc = CAST(@.i AS VARCHAR(32))
SELECT CASE WHEN CONVERT(TINYINT, LEFT(@.ivc, 2))>=30 THEN '19' ELSE '20' END
+ @.ivc
"Sam" <sgpgpjr@.yahoo.ie> wrote in message
news:082a01c3462b$f1924960$a001280a@.phx.gbl...
> Hi all,
> I have a number like so 778625 and want to make
> this a more meaningful date (UK) so how difficult is it to
> add two digits in this case 19 to the front of this number?
> Many thanks
> Sam
>
Showing posts with label difficult. Show all posts
Showing posts with label difficult. Show all posts
Monday, March 19, 2012
Friday, February 24, 2012
add digits to the front
Hi all,
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
Many thanks
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!actually i don't need it to be a date i just need to add 19 to the front
of the number.
Thanks again
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||You can do:
SELECT CAST(CAST(19 AS VARCHAR) + CAST(778625 AS VARCHAR) AS INT)
Another option is to do:
SELECT 19 * POWER(10, LEN(778625)) + 778625
--
- Anith
( Please reply to newsgroups only )|||Not really sure what you mean but something like
select convert(int,'19'+convert(varchar(10),fld))
--
Posted via http://dbforums.com
Subscribe to:
Posts (Atom)