如何将毫秒转换为SQL日期时间?
我转移变量start&像这样结束:
var interval = scheduler.GetSelectedInterval();
var resourceId = scheduler.GetSelectedResource();
var start = _aspxDateTimeToMilliseconds(interval.start);
var end = _aspxDateTimeToMilliseconds(interval.end);
window.location.href =
"FicheAgenda.aspx?Page=ACTION&Mode=Creation&start=" +
start + "&end=" + end +"&resourceId=" + resourceId;
输出:
FicheAgenda.aspx?Page=ACTION&Mode=Creation&start=1334579400000&end=1334584800000&resourceId=24
并且在FicheAgenda.aspx上我想转换这个开始&将结束值转换为日期时间
<asp:SqlDataSource ID="SqlDataSource_Activity" runat="server"
ConnectionString="<%$ ConnectionStrings:OnyxConnectionString %>"
SelectCommand="SELECT DISTINCT [ID_ACTIVITE], [LIBELLE_ACTIVITE]
FROM [ESPTEMPS_ACTIVITE]
LEFT JOIN ESPTEMPS_PROGRAMMATION
ON ESPTEMPS_ACTIVITE.ID_ACTIVITE = ESPTEMPS_PROGRAMMATION.ID_ACTIVITY
WHERE DATEADD(MINUTE,
CONVERT(int, SUBSTRING(HEURE_DEBUT, 3, 2)),
DATEADD(HOUR,
CONVERT(int, SUBSTRING(HEURE_DEBUT, 1, 2)),
DATE_DEBUT))
< convert(datetime,@StartDate)
AND
DATEADD(MINUTE,
CONVERT(int, SUBSTRING(HEURE_FIN, 3, 2)),
DATEADD(HOUR,
CONVERT(int, SUBSTRING(HEURE_FIN, 1, 2)), DATE_FIN))
> convert(datetime,@EndDate) ">
<SelectParameters>
<asp:QueryStringParameter Name="StartDate" QueryStringField="start" />
<asp:QueryStringParameter Name="EndDate" QueryStringField="end" />
</SelectParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
使用dateadd
功能,例如:
dateadd(ms, start, '19800101')
其中1980-01-01
将是您在_aspxDateTimeToMilliseconds
方法中使用的“零”日期。