How can I use date format in YYYY-MM-DD format in asp classic?

I am writing a little code, and I need to add a date to it tomorrow. The format should be YYYY-MM-DD, and I already tried DateAdd ("d", 1, d_now) and returns MM-DD-YYYY. How can I format this to YYYY-MM-DD?

+4
source share
3 answers

Take a look at this post - this may help you ... How to convert a date string in classic asp

+3
source

not enough.

'format a number with the correct amount of digits eg: 9 becomes 09 but 11 stays 11' Function formatNumber(value, digits) if digits > len(value) then formatNumber = String(digits-len(value),"0") & value else formatNumber = value end if End Function 'write the date "manually"' response.write Year(date) & "-" & _ formatNumber(Month(date),2) & _ "-" & formatNumber(Day(date),2) 
+5
source

I have found the answer. This is the easiest way to do this.

d_now = date ()
d = split (DateAdd ("d", 1, d_now), "/")
s = d (2) and "-" and d (0) and "-" and d (1)

+1
source

Source: https://habr.com/ru/post/1335886/


All Articles