Dates in different languages

  • Hello guys, I am sorry if this question is trivial

    Is there a way to make a single insert (in a loop) and take system dates and insert them in different languages without making a new loop for each language.

    Example

    Create table dateLanguage(

    monthName nvarchar(20),

    monthNameEs nvarchar(20),

    monthNameFr nvarchar(20),

    MonthNamePt nvarchar(20)

    )

    So for example

    January,

    Enero,

    Janvier,

    janeiro

    Thanks in advance for the help

  • DECLARE @d AS DATE = '20140101';

    INSERT INTO dateLanguage([monthName],monthNameEs,monthNameFr,MonthNamePt)

    SELECT

    FORMAT(@d, N'MMMM', N'en-us'),

    FORMAT(@d, N'MMMM', N'es-es'),

    FORMAT(@d, N'MMMM', N'fr-fr'),

    FORMAT(@d, N'MMMM', N'pt-pt');

    GO

    SELECT * FROM dateLanguage;

    [font="Courier New"]monthName monthNameEs monthNameFr MonthNamePt

    -------------------- -------------------- -------------------- --------------------

    January enero janvier Janeiro

    [/font]

    ___________________________
    Do Not Optimize for Exceptions!

  • You could use the syslanguages view along with the DelimitedSplit8K[/url] and Crosstabs[/url].

    SELECT

    MAX( CASE WHEN name = 'us_english' THEN s.Item END ) English

    ,MAX( CASE WHEN name = 'Deutsch' THEN s.Item END ) Deutsch

    ,MAX( CASE WHEN name = 'Français' THEN s.Item END ) French

    ,MAX( CASE WHEN name = 'Español' THEN s.Item END ) Spanish

    ,MAX( CASE WHEN name = 'Italiano' THEN s.Item END ) Italian

    FROM sys.syslanguages l

    CROSS APPLY dbo.DelimitedSplit8K( months, ',') s

    GROUP BY s.ItemNumber

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thanks both of you for your help, I appreciate it.

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

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