Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dodi
Starting Member
9 Posts |
Posted - 2003-12-30 : 09:01:28
|
| Hi AllIn Oracle i set the date format like thisAlter session set NLS_DATE_FORMAT='MM/DD/yy';How do i do it in SQL |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-12-30 : 09:12:31
|
| close enough:SET DATEFORMAT mdyvalid options include dmy, mdy, ymd, etc. I don't really know what that command does in Oracle, but note that in SQL Server, this does not affect the display of dates or the formatting of dates. It only affects the order in which character strings are parsed when converting to datetime.OS |
 |
|
|
dodi
Starting Member
9 Posts |
Posted - 2003-12-30 : 09:34:14
|
| 1.Is this function sets the Sql to work with mdy in insert and select2.do i need to return to default after i finish or it's only for my connection |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-12-30 : 09:59:44
|
Why do you want to do this?USE NorthwindGOCREATE TABLE myTable99(Col1 datetime)GODECLARE @x varchar(25)SET @x = '12/31/03'INSERT INTO myTable99(Col1) SELECT @x UNION ALL SELECT GetDate()SELECT CONVERT(varchar(10),Col1,1), Col1 FROM myTable99DROP TABLE myTable99GO Brett8-) |
 |
|
|
dodi
Starting Member
9 Posts |
Posted - 2003-12-30 : 10:03:53
|
| SO i will explain my problemIn my firm we wrote a 4 projects for SQL in usa date formati can not fix now the program to work with different format it's to much code to fix.so in oracle i can solve the problem with :Alter session set NLS_DATE_FORMAT='MM/DD/yy';and now the 4 progrmas work good What can i do in Sql with out changing the Code |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-12-30 : 11:00:18
|
Do you have sql server client tools installed?Look it up in Books Online...quote: SET DATEFORMATSets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. SyntaxSET DATEFORMAT { format | @format_var } Argumentsformat | @format_varIs the order of the dateparts. Can be either Unicode or DBCS converted to Unicode. Valid parameters include mdy, dmy, ymd, ydm, myd, and dym. The U.S. English default is mdy.RemarksThis setting is used only in the interpretation of character strings as they are converted to date values. It has no effect on the display of date values.The setting of SET DATEFORMAT is set at execute or run time and not at parse time.
That makes mention for entry of values...not getting them out...In any event you don't have to do anything to get the data in, in the format you showed us (look at my sample code...did you execute it?)And how is it too much code to change? Did you write it all and never test?Do you use Query Analyzer?You can even use UPDATE with mm/dd/yy...but to SELECT and DELETE, you either need to use CONVERT or do ranges...Anyone else have a fact/opinion on this?USE NorthwindGOCREATE TABLE myTable99(Col1 datetime)GODECLARE @x varchar(25)SET @x = '12/31/03'INSERT INTO myTable99(Col1) SELECT @x UNION ALL SELECT GetDate()SELECT Col1 FROM myTable99SELECT CONVERT(varchar(10),Col1,1), Col1 FROM myTable99UPDATE myTable99 SET Col1 = '12/31/01'SELECT CONVERT(varchar(10),Col1,1), Col1 FROM myTable99DROP TABLE myTable99GO Brett8-) |
 |
|
|
|
|
|
|
|