Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 871697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:40:43+00:00 2026-05-15T10:40:43+00:00

Help me Stackoverflow, I’m close to going all HULK SMASH on my keyboard over

  • 0

Help me Stackoverflow, I’m close to going all “HULK SMASH” on my keyboard over this issue. I have researched carefully but I’m obviously not getting something right.

I am working with a Julian dates referenced from a proprietary tool (Platinum SQL?), though I’m working in SQL 2005. I can convert their “special” version of Julian into datetime when I run a select statement. Unfortunately it will not insert into a datetime column, I get the following error when I try:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

So I can’t setup datetime criteria for running a report off of the Stored Procedure.

Original Value: 733416
Equivalent Calendar Value: 01-09-2009

Below is my code… I’m so close but I can’t quite see what’s wrong, I need my convert statement to actually convert the Julian value (733416) into a compatible TSQL DATETIME value.

SELECT       
org_id, 
CASE WHEN date_applied = 0 THEN '00-00-00' 
ELSE convert(char(50),dateadd(day,date_applied-729960,convert(datetime, '07-25-99')),101) 
END AS date_applied,

CASE WHEN date_posted = 0 THEN '00-00-00'  
ELSE convert(char(50),dateadd(day,date_posted-729960,convert(datetime, '07-25-99')),101) 
END AS date_posted

from general_vw
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:40:44+00:00Added an answer on May 15, 2026 at 10:40 am
    SELECT       
    org_id, 
    CASE WHEN date_applied = 0 OR date_applied < 639906 THEN convert(datetime, '1753-01-01')
    ELSE dateadd(day,date_applied-729960,convert(datetime, '07-25-99'))
    END AS date_applied,
    
    CASE WHEN date_posted = 0 OR date_applied < 639906 THEN convert(datetime, '1753-01-01')
    ELSE dateadd(day,date_posted-729960,convert(datetime, '07-25-99'))
    END AS date_posted
    
    from general_vw
    

    You’re casting to char but want a datetime so that’s one easy fix.

    You were also using ’00-00-00′ as your minimum date, but the minimum TSQL date is ‘1753-01-01’. Alternatively you could use something like (‘1900-01-01’) but that would need a change to the “less than” date_applied comparer.

    I’ve added a “less than” date_applied comparer too. I calculated this as “SELECT 729960 + datediff(day,convert(datetime, ’07-25-99′), convert(datetime,’1753-01-01′))”. Any number less than this would cause a date underflow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I -with some stackoverflow users help- have developed this tooltip script using Jquery and
Now that I have decided upon Firebird , with the help of StackOverflow :),
Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some
with the help of resources of stackoverflow, i have managed to make autocomplete on
Another jQuery issue... I have tried this several times using class and id elements
Please help Stackoverflow! I have a MapInterface class in AS3 that inherits from Interface
With help from StackOverflow today, I have gotten my data layer constructed return data
using BouncyCastle and with help from a stackoverflow question I got this: using System.Net.Sockets;
With the help of some very gracious stackoverflow contributors in this post , I
With the help of StackOverflow I have a MySQL query that works. After making

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.