0

I am getting a bit worked up here. I am working on new site in Classic Asp.

Built everything and all is working fine and now comes the time to test with some data. The moment we come to date related data everything goes crazy.

i run a query on my SQL CE that comes with WebMatrix 2, and inserted the date into the field using Getdate(), and checked it out, the format is mm/dd/yyyy.

now on the webpage if i do a response.write Date(), its in dd/mm/yyyy format.

FormatDateTime(nDate,vbshortdate) returns the date in yyyy/mm/dd format.

Ok that was all about the background and facts.

So now i have the date in the field called newDate. i populate it to my text box using a variable. Now if i try to update the db its an error. I response.write the sql query, and the date is now string in the right to left(arabic) style.

I do believe this may be a localization issue, if someone can help me out of this predicament.

I must also add, that in my webpages i have been using charset=utf-8.

many thanks

4

2 回答 2

1

我以数据存储在名为Employees的表中的形式使用了以下代码:

@{
var record = UrlData[0].AsInt();
var id=Request["id"];
var db = Database.Open("StarterSite");
var SQLSELECT = "SELECT * FROM Employees where Id=@0";

// Select the requested record //

var emp = db.QuerySingle(SQLSELECT,id);
var EmployeeDOB = emp.DateOfBirth;

EmployeeDOB=Request["formDOB" ];

// Update the database with data from the form //

var SQLUPDATE = "UPDATE Employees Set EmployeeDOB=@1 where Id=@0";
    db.Execute(SQLUPDATE, EmployeeId, 
    EmployeeDOB);
}
<form method="post">

<label for="formDOB" @if (!ModelState.IsValidField("formDOB")) {<text>class="error-     label"</text>} >DOB:</label>
<input  type="date" name="formDOB" value="@EmployeeDOB.ToString("MM/dd/yyyy")" style="display:inline-block;margin-top:5px;margin-bottom:5px;max-width:80px;" onblur=' '/>@Html.ValidationMessage("formDOB")<br />

EmployeeDOB 在表中声明为数据时间。

输入字段显示为格式为 MM/dd/yy 的日期,不含时间,但在表中存储为日期时间,即 11/22/2012 8:00:00 PM。

于 2012-11-23T03:56:54.097 回答
0

SQL CE 在存储日期时不会“格式化”日期。WebMatrix 格式化它以在数据库工具中显示。如果您想使用 VBScript 在浏览器中控制日期的显示格式,您有多种选择。请参阅VBScript 中的日期格式。另请参阅Can I make VBScript Format Dates For Me

于 2012-10-13T12:38:23.893 回答