Results 1 to 4 of 4

Thread: Julian date into our date format

  1. #1
    Join Date
    Nov 2002
    Posts
    231

    Julian date into our date format

    Hello,
    anybody has query regarding converting date from Julian into our our dateformat?.
    Your Help really apreciated,
    Thanks,
    Ravi

  2. #2
    Join Date
    Oct 2002
    Posts
    42
    Look in books on line at the CONVERT function.

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    it depends on what format of Julian date u r talking about

    yyddd

    tttt.ddd

    ddd

    History
    -------
    Julian date based on the number of days since noon, Universal Time on January 1, 4713 BCE. Jan 1, 1900 was Julian date 693596.

  4. #4
    Join Date
    Nov 2002
    Posts
    231

    Julian date into our calender date conversion

    finaly,
    I have created the function for julain to our calender date.

    Here is the function and you can change according to your requirment too.

    drop function format_date_julian
    go
    CREATE FUNCTION format_date_julian
    ( @inp_date float )
    RETURNS DATETIME
    AS
    BEGIN
    declare @strDate varchar(31),
    @iYear varchar(31),
    @fmt_date datetime

    if( @inp_date = 0 or @inp_date is null )
    begin
    return null
    end

    select @strDate = cast( @inp_date as varchar(31))

    select @iYear = cast(left(@strDate,DATALENGTH(@strDate)-3) as varchar(31))

    select @iYear =
    CASE DATALENGTH(@iYear)
    WHEN 0 THEN '2002'
    WHEN 1 THEN '200' + @iYear
    WHEN 2 THEN '20' + @iYear
    else @iYear
    END

    select @fmt_date = cast(@iYear as datetime)
    select @fmt_date = dateadd(dd,cast(right(@strDate,3) as int) - 1,@fmt_date)

    return @fmt_date
    end



    -- select dbo.format_date_julian(2002)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •