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 |
johnb
Starting Member
8 Posts |
Posted - 2004-12-02 : 11:04:58
|
Hello,I'm having trouble trying to change the format on a date parameter to DD/MM/YYYY instead of (MM/DD/YYYY). Does anybody know whether it can be done?ThanksJohn |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-12-02 : 11:13:42
|
A better way to pass dates are in ISO format (YYYYMMDD). There are no separators and SQL Server will always interpret it correctly. |
 |
|
johnb
Starting Member
8 Posts |
Posted - 2004-12-02 : 11:43:35
|
Thanks for this but the report doesn't seem to work when I key-in a parameter in YYYYMMDD. The only format it takes is MM/DD/YYYY (including "/") |
 |
|
johnb
Starting Member
8 Posts |
Posted - 2004-12-02 : 11:59:43
|
Managed to solve the problem...I created this function (below) which will convert dates in this format "2003-10-08 00:00:00.000" to be this text string "08/10/2003" (how us UK people like it!). I then changed the report so that the parameter looks at this function of the date and all appears to work ok.CREATE FUNCTION GBDate(@Date datetime)RETURNS CHAR(10)ASBEGIN RETURN left(case(len(datepart(dd,@Date))) when 1 then convert(char,'0'+convert(char,datepart(dd,@Date))) else convert(char,datepart(dd,@Date)) end,2)+'/'+ left(case(len(datepart(mm,@Date))) when 1 then convert(char,'0'+convert(char,datepart(mm,@Date))) else convert(char,datepart(mm,@Date)) end,2)+'/'+ left(convert(char,datepart(yy,@Date)),4)END |
 |
|
|
|
|
|
|