1

Please see the issue details and share the solution if you have. Thank you in advance. Issue: Windows 2012/IIS 8.5 Classic ASP date format changing when we append with string. For example, date value 01/12/2016 (Jan 12th 2016) have been changed to 12/01/2016 (Dec 1st 2016) if we append with the string.

Source Code: (date.asp)

<%
Dim fordate
Dim fdate
fordate = Request.QueryString("fordate")
Response.Write(fordate)
fdate = cdate(fordate)
Response.Write(fdate)
Dim strsql
strsql = "exec testsp " & fdate
Response.Write(strsql)
%>

Please see the output

user692942
  • 16,398
  • 7
  • 76
  • 175
  • You have two servers with different system date formatting set, check the regional settings in the Control Panel on each server. This has nothing to do with IIS when a date is converted it becomes *"A String containing a date in the short-date format of your system"*. You can use [`FormatDateTime()`](https://msdn.microsoft.com/en-us/library/8aebkz6s%28v=vs.84%29.aspx?f=255&MSPPError=-2147217396) which gives you some control over this but anything more then that you need to build the date format yourself. See [Format current date and time](http://stackoverflow.com/a/22575530/692942). – user692942 Feb 10 '16 at 12:05
  • Possible duplicate of [Format current date and time](http://stackoverflow.com/questions/22574092/format-current-date-and-time) – user692942 Feb 10 '16 at 12:10
  • did any of the suggestions help? – user692942 May 04 '16 at 13:50

1 Answers1

1

When casting Date / Time to a String in VBScript the following applies

Quote from MSDN - VBScript Reference - CStr Function
A String containing a date in the short-date format of your system

The effect by default whatever the "short-date" format settings are for dates values on the system# (usually found under Control Panel -> Language but varies by OS) is used when displaying String representations of date values in VBScript.

# - By "System" we mean the Server / Computer whether it be in a client / server side environment.


Useful Links

Community
  • 1
  • 1
user692942
  • 16,398
  • 7
  • 76
  • 175