From: Greg Larsen on 15 Jun 2006 12:09 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 15 Jun 2006 12:27 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 19 Jun 2006 11:22 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 27 Jun 2006 12:26 Thank you very much.
From: Alur on 27 Jun 2006 12:27 Thank you.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: The context connection is already in use (SQLCLR) Next: Bulk Insert from Excel |