norweigen date time problem.

  • I have an vb6 (dont snicker) application that is used all over the world.

    some users refuse to leave the regional setting to english and i am haveing an issue.

    a date of '01-okt-2014' is being passed and sql has a hissy fit.

    or (01-mai-2014 or 01-des-2014) is there a way to convert this to a REAL date time so i dont get

    conversion failed when converting date and/or time from char string

  • found my own solution

    SELECT dbo.GetEnglishDate('Portuguese', '01-ago-2014')

    CREATE FUNCTION GetEnglishDate

    (@language VARCHAR(25), @DateString VARCHAR(30))

    RETURNS VARCHAR(30)

    AS

    Begin

    --DECLARE @language VARCHAR(25)

    --DECLARE @DateString VARCHAR(30)

    DECLARE @langMonths VARCHAR(100)

    DECLARE @engMonths VARCHAR(100)

    DECLARE @frnMonth VARCHAR(3)

    DECLARE @engMonth VARCHAR(3)

    --SET @language = 'Portuguese'

    --SET @DateString = '01-ago-2014'

    SELECT @langMonths = shortmonths FROM sys.syslanguages WHERE alias = (@language)

    SELECT @engMonths = shortmonths FROM sys.syslanguages WHERE alias = ('English')

    SET @frnMonth = SUBSTRING(@DateString,4,3)

    set @engMonth = SUBSTRING(@engMonths,CHARINDEX(SUBSTRING(@DateString,4,3),@langMonths),3)

    SET @datestring = REPLACE(@datestring,@frnmonth,@engmonth)

    Return @datestring

    END

  • lee.hopkins (7/31/2014)


    I have an vb6 (dont snicker) application that is used all over the world.

    some users refuse to leave the regional setting to english and i am haveing an issue.

    a date of '01-okt-2014' is being passed and sql has a hissy fit.

    or (01-mai-2014 or 01-des-2014) is there a way to convert this to a REAL date time so i dont get

    conversion failed when converting date and/or time from char string

    Something like

    DECLARE @DATE_STR VARCHAR(20) = CONVERT(DATE,REPLACE(REPLACE(REPLACE('01-DES-2014','s','c'),'y','i'),'K','C'),113);SELECT @DATE_STR;

    😎

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply