Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

converting zulu format to date and time format

anjali5Nov 10 2011 — edited Nov 10 2011
I want to convert zulu format to regular dateand time format. so for e.g I have this date and time in my table

021731ZJUN06, I want to convert it to 2006-06-02 17:31:00

I wrote this in sql server, but don't know how to do this in oracle

ALTER function [dbo].[ZULUToDateTime](@initDate varchar(20))
RETURNS datetime
AS
BEGIN
DECLARE @NewDate datetime
SET @NewDate = NULL
IF @initDate <> 'false'
BEGIN
SET @NewDate= CONVERT(datetime,LEFT(@initDate,2)+ ' ' + STUFF(right(@initDate,5),4,0,' ') + ' ' +STUFF(SUBSTRING(@initDate,3,4),3,0,':'),121)

END

RETURN @NewDate

END
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2011
Added on Nov 10 2011
4 comments
3,943 views