好的,所以我的代码工作正常,但我需要在OrderDate中添加一天,同时保持相同的格式yyyy-mm-dd
非常感谢任何帮助!
<%
inDate = oRS("ordDate")
' get each date component
thisMonth = datepart("M",inDate)
thisDay = datepart("D",inDate)
thisYear = datepart("yyyy",inDate)
' check for the length of the month and day components
if len(thisMonth) < 2 then thisMonth = "0" & thisMonth
if len(thisDay) < 2 then thisDay = "0" & thisDay
' Create the date in your format you posted above
OrderDate = thisYear & "-" & thisMonth & "-" & thisDay
%>
答案 0 :(得分:1)
使用您的代码作为示例,只需使用DateAdd()
将日期增加 1个日历日;
<%
inDate = oRS("ordDate")
'Add one day
inDate = DateAdd("d", 1, inDate)
' get each date component
thisMonth = datepart("M",inDate)
thisDay = datepart("D",inDate)
thisYear = datepart("yyyy",inDate)
' check for the length of the month and day components
if len(thisMonth) < 2 then thisMonth = "0" & thisMonth
if len(thisDay) < 2 then thisDay = "0" & thisDay
' Create the date in your format you posted above
OrderDate = thisYear & "-" & thisMonth & "-" & thisDay
%>
有关使用日期的详细信息,请参阅Classic ASP - Format current date and time。
答案 1 :(得分:0)
试试这个:
dim sOrderDate
sOrderDate=cInt(thisDay)+1
if len(thisDay) < 2 then thisDay = "0" & thisDay
if len(sOrderDate) < 2 then sOrderDate = "0" & sOrderDate
OrderDate = thisYear & "-" & thisMonth & "-" & sOrderDate
这样你就可以保留原始日期(thisDay)进行操作,订单日期变成明天(或其他)日期。