From: Greg Larsen on
DBCC USEROPTIONS

Another solution is to write some code similar to this:

SET DATEFORMAT ydm
GO
DECLARE @datevar datetime
SET @datevar = '01/02/03'
SELECT cast(datepart(month,@datevar)as char(1))
+ cast(datepart(day,@datevar)as char(1))

SELECT case cast(datepart(month,@datevar)as char(1))
+ cast(datepart(day,@datevar)as char(1))
when 31 then 'dym'
when 21 then 'dmy'
when 12 then 'mdy'
when 13 then 'myd'
when 32 then 'ydm'
when 23 then 'ymd'
else '???'
end

"Alur" wrote:

> How can I determine current
> SET DATEFORMAT ?
From: Kalen Delaney on
Hi Greg

This is a really cool solution! I hope you don't mind that I cleaned it up
just a bit:

SET DATEFORMAT ydm; -- For testing
GO
DECLARE @datevar datetime,
@datecode char(2);

SET @datevar = '01/02/03'

SELECT @datecode = cast(datepart(month,@datevar)as char(1))
+ cast(datepart(day,@datevar)as char(1));

SELECT @datecode AS datecode; -- For troubleshooting

SELECT CASE @datecode
when '31' then 'dym'
when '21' then 'dmy'
when '12' then 'mdy'
when '13' then 'myd'
when '32' then 'ydm'
when '23' then 'ymd'
else '???'
END AS DATEFORMAT;

--
HTH
Kalen Delaney, SQL Server MVP


"Greg Larsen" <GregLarsen(a)discussions.microsoft.com> wrote in message
news:E90E6795-5952-4D4F-AAB5-00B764EB5130(a)microsoft.com...
> DBCC USEROPTIONS
>
> Another solution is to write some code similar to this:
>
> SET DATEFORMAT ydm
> GO
> DECLARE @datevar datetime
> SET @datevar = '01/02/03'
> SELECT cast(datepart(month,@datevar)as char(1))
> + cast(datepart(day,@datevar)as char(1))
>
> SELECT case cast(datepart(month,@datevar)as char(1))
> + cast(datepart(day,@datevar)as char(1))
> when 31 then 'dym'
> when 21 then 'dmy'
> when 12 then 'mdy'
> when 13 then 'myd'
> when 32 then 'ydm'
> when 23 then 'ymd'
> else '???'
> end
>
> "Alur" wrote:
>
>> How can I determine current
>> SET DATEFORMAT ?


From: Greg Larsen on
No problem on the clean up. New script is much better.

"Kalen Delaney" wrote:

> Hi Greg
>
> This is a really cool solution! I hope you don't mind that I cleaned it up
> just a bit:
>
> SET DATEFORMAT ydm; -- For testing
> GO
> DECLARE @datevar datetime,
> @datecode char(2);
>
> SET @datevar = '01/02/03'
>
> SELECT @datecode = cast(datepart(month,@datevar)as char(1))
> + cast(datepart(day,@datevar)as char(1));
>
> SELECT @datecode AS datecode; -- For troubleshooting
>
> SELECT CASE @datecode
> when '31' then 'dym'
> when '21' then 'dmy'
> when '12' then 'mdy'
> when '13' then 'myd'
> when '32' then 'ydm'
> when '23' then 'ymd'
> else '???'
> END AS DATEFORMAT;
>
> --
> HTH
> Kalen Delaney, SQL Server MVP
>
>
> "Greg Larsen" <GregLarsen(a)discussions.microsoft.com> wrote in message
> news:E90E6795-5952-4D4F-AAB5-00B764EB5130(a)microsoft.com...
> > DBCC USEROPTIONS
> >
> > Another solution is to write some code similar to this:
> >
> > SET DATEFORMAT ydm
> > GO
> > DECLARE @datevar datetime
> > SET @datevar = '01/02/03'
> > SELECT cast(datepart(month,@datevar)as char(1))
> > + cast(datepart(day,@datevar)as char(1))
> >
> > SELECT case cast(datepart(month,@datevar)as char(1))
> > + cast(datepart(day,@datevar)as char(1))
> > when 31 then 'dym'
> > when 21 then 'dmy'
> > when 12 then 'mdy'
> > when 13 then 'myd'
> > when 32 then 'ydm'
> > when 23 then 'ymd'
> > else '???'
> > end
> >
> > "Alur" wrote:
> >
> >> How can I determine current
> >> SET DATEFORMAT ?
>
>
>
From: Alur on
Thank you very much.
From: Alur on
Thank you.