可能重复:
C#中的格式化日期
我想以格式显示日期May 16, 2011.我已经使用了格式String.Format("{0:D}",我得到了输出Monday, May 16, 2011.所以请任何人告诉我如何能够以下列格式显示日期时间May 16, 2011
提前感谢
我有一个转发器,我想在属性上添加一个鼠标到它的项目.
是否可以在运行时添加属性,如果是,那么如何?
我有一个tblEmpDetail包含列的表CreatedDate.
我想为每个创建的日期添加72小时,所以如果创建的日期是,2012-07-14 07:21:19.180那么我想要输出2012-07-17 07:21:19.180.
有人能让我知道我怎么能达到这个目的?
其实我想要做的就是去每行然后检查一下
getdate() - createddate
Run Code Online (Sandbox Code Playgroud)
等于或小于72小时; 然后我需要增加72小时createddate.否则我希望该列为null.我把我的代码粘贴到了我所做的事情上.
Declare @PassedTime datetime
set @PassedTime= DATEDIFF(HH,Createddate, GETDATE())
if CONVERT(varchar(20),@PassedTime,108)>=CONVERT(varchar(20),'72:00:00',108)
begin
select empno,empName,CreatedDate,dateadd(HH,72,CreatedDate)BD from tblEmpDetail
end
else
begin
select empno,empName,CreatedDate,'' as BD from tblEmpDetail
end
Run Code Online (Sandbox Code Playgroud) 我有两个不同的列来存储日期和时间。一种是保存日期,另一种是时间。在我使用当地时间之前,它工作正常。现在,我想为亚利桑那州设置时间,为此,我将日期时间转换为UTC时间,并使用Used TimeZoneIfo的方法ConvertTime来获取亚利桑那州的时间。现在我的问题是我可以使用它获取日期,但是在我节省时间的同时,我希望将其以12小时格式转换为24小时。我的代码是
DateTime UniversalScheduleDate = Convert.ToDateTime(txtDate.Text).ToUniversalTime();
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(Session["TimeZone"].ToString());
objSchdl.SDate = TimeZoneInfo.ConvertTime(UniversalScheduleDate, timeZoneInfo);
DateTime UniversalStartTime = Convert.ToDateTime(txtStartTime.Text).ToUniversalTime();
objSchdl.Stime = TimeZoneInfo.ConvertTime(UniversalStartTime, timeZoneInfo).ToString();
Run Code Online (Sandbox Code Playgroud)
请帮我..
我使用以下方式比较两个日期:
if CONVERT(varchar(20), @ScheduleDate, 101) >= CONVERT(varchar(20), @CurrentDateTime, 101)
Run Code Online (Sandbox Code Playgroud)
这是本年度工作正常,但是当谈到在每年像一个日期是12/31/2012和1/1/2013那么它不工作.
请帮帮我,我该如何解决这个问题.
我很少使用像"http%3a // test.dev.test.com/posts/test test"这样的网址,我想用" http://test.dev.test.com/posts/test test "替换它"在窗口加载功能上,我已尝试过以下代码,但它没有更新锚标记的URL.
$('a[href*="http%3a//"]').each(function () {
this.href = this.attr('href').replace('http%3a//', 'http://');
});
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它不起作用.请帮我.
编辑::
<a href="http%3a//test.dev.test.com/posts/test test" rel="bookmark" class="aChangeUrl" id="ctl00_lnkEntry">New test in March</a>
Run Code Online (Sandbox Code Playgroud) 我是MVC的新鸟.我想将Model传递给Ajax调用,我编写以下代码来执行此操作.但它总是将NULL传递给所有属性.
$("#btnsubmit").click(function () {
alert('hello');
var productModel = {
Name: 'ram@mailinator.com',
Address: "Chai"
};
$.ajax({
type: "POST",
url: '@Url.Action("ContactDistributor", "AjaxCallTest")',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ model: productModel }),
dataType: "json",
success: function () { alert('Success'); },
error: function (xhr) {
alert(xhr.error);
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
型号:
public class AjaxCalltestModal
{
public int Id { get; set; }
public String Name { get; set; }
public String Address { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
[HttpPost]
public ActionResult ContactDistributor(WebApplication1.Models.AjaxCalltestModal a)
{ …Run Code Online (Sandbox Code Playgroud) 如何使用LINQ的Contains()或Any()函数检查下面显示的数组或列表是否包含给定值?
这是我的代码:
int[] array3 = { 1, 2, 3, 4, 5, 6 };
List<int> tyest = array3.ToList<int>();
if (tyest.Any(2)) {
}
Run Code Online (Sandbox Code Playgroud) select t.*
into #temp
from
(
select 'a' as a
union all
select 'b' as a
) as t
select * from #temp
drop table #temp
Run Code Online (Sandbox Code Playgroud)
我通常在SQL服务器上执行此操作,其中我创建一个临时表.语法"into #temp"在DB上创建非物理表,而"into temp"将在DB上创建物理表.
我在MySQL中的问题是转换上面的MSSQL语句.我想要的是创建一个没有在数据库上物理创建的临时表.我们在MySQL中有这个功能吗?
我有一个进程,客户端希望我总是显示带有两位小数的金额,或者带有小数值或不带小数值
例如:如果17然后我想显示"17.00",如果是17.2然后我想显示"17.20"或者如果17.2033然后我想显示"17.20"我试过String.Format("{0:.##}", rec.Rate)
它不起作用,请帮助我我该怎么做...提前感谢
c# ×4
asp.net ×3
sql-server ×3
jquery ×2
.net ×1
addattribute ×1
ajax ×1
anchor ×1
any ×1
arrays ×1
asp.net-mvc ×1
comparison ×1
date ×1
datetime ×1
decimal ×1
foreach ×1
format ×1
html ×1
insert ×1
javascript ×1
list ×1
mysql ×1
repeater ×1
sql ×1
temp-tables ×1
time ×1
utc ×1