How can I convert milliseconds into SQL datetime ?
I transfer the variable start & end like this:
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;
the output:
FicheAgenda.aspx?Page=ACTION&Mode=Creation&start=1334579400000&end=1334584800000&resourceId=24
and on FicheAgenda.aspx I want to convert this start & end value into a datetime
<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>
Use the dateadd
function, for example:
dateadd(ms, start, '19800101')
where 1980-01-01
would be the "zero" date that you use in your _aspxDateTimeToMilliseconds
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.