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 |
|
abhi143
Starting Member
32 Posts |
Posted - 2006-03-01 : 09:03:46
|
| hi all of u...i want to write stored procedure, in which there will be two string.i.e 15/06/2005 and 15/10/2005(mm/dd/yyyy) format.Note that it is not Date data type..now i want to compare that if Date1 is greater than Greater Date2then -----else ----endthanksabhi |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-03-01 : 09:09:33
|
| convert the strings to datetime type |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-01 : 09:11:01
|
| Why do you want to use varchar datatype for Dates?Use DateTime datatype to avoid unnecessary conversions. Also dont format to local settings. Use universal format yyyy-mm-dd so that your date is 2005-06-15 and not 15/06/2005Use Datetime parameters in stored procedure and compare them asIf @date1>@date2 then---else---MadhivananFailing to plan is Planning to fail |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-03-01 : 09:26:19
|
| [code]Declare @d1 varchar(30), @d2 varchar(30)Set @d1 = '15/06/2005' Set @d2 = '15/10/2005'Print convert(datetime,@d1,103)Print convert(datetime,@d2,103)if convert(datetime,@d1,103) < convert(datetime,@d2,103)Begin Print ' d1 > d2 'EndelseBegin Print ' d1 < d2 'End[/code] |
 |
|
|
|
|
|