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 |
cjhardie
Yak Posting Veteran
58 Posts |
Posted - 2007-04-11 : 17:20:13
|
private string GetDefault(string defaultCode) { string val = ""; switch (defaultCode) { case "LoginID": val = base.LoginID.ToString(); break; case "Today": val = DateTime.Today.ToShortDateString(); break; case "MonthFrom": DateTime theDateTime = DateTime.Today.AddMonths( 1 ); val = theDateTime.AddDays( -1 ).ToShortDateString(); break; } return val;I want to add a case like "FirstofCurrentMonth" Where the default is the first of the current month. any help? |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-04-11 : 17:25:06
|
Try this:case "FirstofCurrentMonth":val = DateTime.Today.AddDays(-DateTime.Today.Day + 1);SQL Server Helperhttp://www.sql-server-helper.com |
|
|
cjhardie
Yak Posting Veteran
58 Posts |
Posted - 2007-04-11 : 17:35:39
|
I received an error messagecannot implicitly convert type 'System.DateTime' to 'String' |
|
|
cjhardie
Yak Posting Veteran
58 Posts |
Posted - 2007-04-11 : 17:59:25
|
I had to add ToShortDateString()then it worked, Thanks |
|
|
|
|
|