使用DateAdd()特殊格式 [英] DateAdd() in Special Format
问题描述
我已经尝试了所有我看到的一个月添加到一个特定日期,然后返回一个特定格式的方式,但我无所适从。这里是我的code,但我需要对其进行格式化:
更换(FORMATDATETIME(DATEADD(M,1,请求(DATE)),0),/ , - )及')
请求(DATE)
在 YYYYY-MM-DD HH:MM:SS
格式,这就是我需要怎么新的日期。
这可能会有帮助:
<$p$p><$c$c>FormatDateTime(DateAdd(\"M\",1,DateSerial(Left(request(\"date\"),4),Mid(request(\"date\"),9,2),Mid(request(\"date\"),6,2))) &安培; 与&amp; MID(请求(DATE),12,8),D,0)它基本上将字符串转换为以本机格式的有效日期,1月要求增加了,然后重新生成字符串。
请注意:请求(DATE)看起来好像返回当前日期时间因此这样可能会产生一个最终值是一秒钟左右出运行它,如果这是一个问题,那么你将得到更好的存储静态在一个变量的值,否则这应该有希望是好的。
I've tried all the ways I see to add a month to a certain date then return that in a specific format but I'm at a loss. Here's my code but I need to format it:
replace( formatdatetime( dateadd( "m" , 1 , request("date") ), 0 ) , "/" , "-" ) & "' )
request("date")
is in yyyyy-dd-mm hh:mm:ss
format and that's how I need the new date.
This may help:
FormatDateTime(DateAdd("M",1,DateSerial(Left(request("date"),4),Mid(request("date"),9,2),Mid(request("date"),6,2))) & " " & Mid(request("date"),12,8),d,0)
It basically converts the string to a valid date in the native format, adds the 1 requested month and then rebuilds the string.
NOTE: request("date") looks as though it returns the current datetime so running it in this way may generate a final value that is a second or so out, if that's a problem then you will be better storing a static value in a variable, otherwise this should hopefully be ok.
这篇关于使用DateAdd()特殊格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!