The [Lead Time Calculation] field within the "Item" database table

I have a calculated field in Microsoft Dynamics NAV that I need to display via a website for lead time for Parts in one of our databases. This particular field is the [Lead Time Calculation] field within our “Item” database table.

In Navision, this field displays as a number followed by either the letter D (for day(s)), the letter W (for week(s)), the letter M (for month(s)), the letter Q (for quarter(s)), the letter Y (for year(s)) or the letters WD (for work day(s)). For example, if the [Lead Time Calculation] value is 150D, this translates to be 150 days and if the [Lead Time Calculation] value is 150WD, this translates to be 150 work days.

The problem is that in our SQL database table, these values of D, W, M, Q, Y and WD all display as the character: . So 150D on the Microsoft Dynamics NAV side ends up being 150 on the SQL side and 150WD on the Microsoft Dynamics NAV side also ends up being 150 on the SQL side.

Can anyone help me figure out how to convert this character of back to its proper value of either D, W, M, Q, Y and WD within our SQL database?

Please let me know.

Thanks,

Nathan

A similar question was asked not long time ago:

How to get DateFormula data from SQL query

But I guess not really the answer you were looking for…

Erik,

I agree that this “How to get DateFormula data from SQL query” question is similar to my question; however, I would like to know how to retrieve this DateFormula data from the SQL database table without modifying anything on the Microsoft Dynamics NAV side.

-Nathan

Nathan,

Well the question was answered by some of the best experts in that area, so I don’t really think that you find a better answer. I’m sorry but it seams what you ask is not possible.

I had the same problem today so I have used a couple of case statements.

‘Safety Lead Time’ =

CASE

WHEN item.[Safety Lead Time] = ‘’ THEN ‘’

WHEN ASCII(SUBSTRING(item.[Safety Lead Time],LEN(item.[Safety Lead Time])-1,1)) <> 1 THEN

CASE ASCII(RIGHT(item.[Safety Lead Time],1))

WHEN 2 THEN ‘Day’

WHEN 3 THEN ‘Weekday’

WHEN 4 THEN ‘Week’ WHEN 5 THEN ‘Month’

WHEN 6 THEN ‘Quarter’ WHEN 7 THEN ‘Year’

ELSE ‘ERROR’

END

WHEN ASCII(SUBSTRING(item.[Safety Lead Time],LEN(item.[Safety Lead Time])-1,1)) = 1 THEN

CASE ASCII(RIGHT(item.[Safety Lead Time],1))

WHEN 2 THEN ‘Current Day’

WHEN 3 THEN ‘Current Weekday’

WHEN 4 THEN ‘Current Week’

WHEN 5 THEN ‘Current Month’

WHEN 6 THEN ‘Current Quarter’

WHEN 7 THEN ‘Current Year’

ELSE ‘ERROR’

END

ELSE ‘ERROR’

END