Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp-classic

Im writing an small code and I need to add tomorrow's date on it. The format should be YYYY-MM-DD and I already tried " DateAdd("d",1,d_now) and it returns MM-DD-YYYY. How can I format this to YYYY-MM-DD ?

like image 835
Jay Avatar asked Jan 17 '11 20:01

Jay


2 Answers

format is 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) 
like image 80
Caspar Kleijne Avatar answered Nov 15 '22 11:11

Caspar Kleijne


Take a look at this post - it might help you out... How to transform a date-string in classic asp

like image 31
Luke Avatar answered Nov 15 '22 10:11

Luke