June 8, 2004 at 1:50 am
Hi there,
Googled the internet, found the question posed several times, no answer however! I have this integer value always as format 20040522, yyyymmdd. I wish to convert this to datetime. When looking in BOL under CAST and CONVERT I see that this is an implicit conversion. I translate this as: put a recognizable integer into a datetimefield, and it will be stored as such.
Not so. At least, I don't get it to work. Maybe you guessed, I'm trying to do something with the sysjobhistory table, where date is stored in this format. I've tried several converts, no luck sofar. I thought this should be simple, but...
TIA,
Hans Brouwer
Greetz,
Hans Brouwer
June 8, 2004 at 2:00 am
Not sure if I understand you, but are you looking for something like this:
DECLARE @a INT
SET @a = 20040522
SELECT CONVERT(DATETIME,CONVERT(CHAR(8),@a,112))
------------------------------------------------------
2004-05-22 00:00:00.000
(1 row(s) affected)
???
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 8, 2004 at 2:06 am
That's it, tnx. And I know what I did wrong now, so tnx again.
Greetz,
Hans Brouwer
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply