DateAdd() in Special Format

后端 未结 3 644
星月不相逢
星月不相逢 2020-12-07 06:02

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:

3条回答
  •  醉酒成梦
    2020-12-07 06:41

    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.

提交回复
热议问题