Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 18th, 2004, 06:21 AM
Authorized User
 
Join Date: Oct 2004
Location: Ballybrittas, Laois, Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Behavior of Date/Time Format Differs When Accessed

Hi folks,
Our problem is that the behavior of Date/Time Format Differs When Accessed from Active Server Pages. For example our regional settings are dd/MM/yyyy but when an ASP page is accessed it writes the date as MM/dd/yyyy. We found an article on the Microsoft website and followed the instructions as you can see here, http://www.barrowvale.com/IIS5DateTimeDiffers/. It still hasn't solved the problem though.

Has anybody any ideas?

Kind Regards
Oliver Dempsey
Barrowvale Technology
Reply With Quote
  #2 (permalink)  
Old October 20th, 2004, 10:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Was the server rebooted once after making the changes? Not sure if that could have helped. Just a thought. Let me try that out in my PC and let you know.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old October 20th, 2004, 12:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you are right, those steps doesn't help. I tried all that mentioned in that link and rebooted the system too. No help. Instead you can use
Code:
FormatDateTime( Now(), 2)
That should help.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #4 (permalink)  
Old October 20th, 2004, 06:39 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Oliver

ahhh the date thing, in Austrlia we are dd/mm/yyy also. you can never predict what date/regional settings somebody browsing your web site has, I wrap functions around ALL dates to force the date format I wish. Here are two simple function that will sort this for you, this is cut n paste code
----------------------------------
  function ddmmyyyy(varDate)
     ddmmyyyy = Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate))
  end function

  function mmddyyyy(varDate)
     mmddyyyy = Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate))
  end function

  response.write ddmmyyyy(now) & " = dd/mm/yyyy format<Br>"

  response.write mmddyyyy(now) & " = mm/dd/yyyy format<Br>"
----------------------------------

Wind is your friend
Matt
Reply With Quote
  #5 (permalink)  
Old October 20th, 2004, 06:46 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

BTW : If your machine is showing a mm/dd/yyyy result from the now function your PC's regional settings are not dd/mm/yyyy

You may say in the control panel is say's it is, yes myn did to. There are several places you have to make changes, we have a proceedure for this somewhere - I will look for it for you.

Wind is your friend
Matt
Reply With Quote
  #6 (permalink)  
Old October 21st, 2004, 12:00 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I had this date format problem for so long time. Finally I could solve it by following this strategy.

1) The date to be stored in database is always formatted in MM/DD/YYYY format. Then proper date delimiters need to be used. ' for SQL server and # for MS Access.

2) While retrieving dates, proper functions were created (Just like what Matt did) which split date field value into date, month and year. Then they were concatenated using proper seperator and displayed.
3) While passing date values to date functions (datediff etc.), I need to pass it in MM/DD/YYYY format using proper delimiters.

4) In the case of SQL server, you need to run the following query to set the format as MM/DD/YYYY.

qry_set_dateformat="SET DATEFORMAT mdy"
cnn_test.execute qry_set_dateformat

where cnn_test is the ADODB connection object.

These things will make date operations independent of regional settings at server.
Reply With Quote
  #7 (permalink)  
Old October 21st, 2004, 09:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, there are different ways to get the date format that you like to work with(Split them into dd, mm, yyyy and concatenate as required or use FormatDateTime() function).

When dealing with date format on SQL server, I would always suggest to use "yyyy-mm-dd hh:mm:ss.mss" format as that is the default format for date values stored in sql server, still that can be changed to any format that you require.

Also it is not a must to pass date in a specific mm/dd/yyyy format for datediff to get the right result. You can also pass that as "yyyy-mm-dd" and use the same standard wherever it deals with date values.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #8 (permalink)  
Old October 21st, 2004, 09:51 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thanks Vijay for the information that it is stored actually in yyyy/mm/dd format. Actually, I thought it is in mm/dd/yyyy format.

This also helps me in generalising some standards. It is in this format dates are stored in MySQL also.
Reply With Quote
  #9 (permalink)  
Old October 21st, 2004, 09:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

One more doubt. What about the seperator between date, month and year parts ? Which is the "universal one" ? - or /
Reply With Quote
  #10 (permalink)  
Old October 21st, 2004, 11:26 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

IMHO "yyyy-mm-dd hh:mm:ss.mss" is the way to go as it uses ISO standard date & time formats, so shuold therefore be supported by most products.

HTH,

Chris

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
date time format vb certified Pro VB 6 4 December 18th, 2009 08:16 AM
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
Format Date to time field KennethMungwira VB.NET 3 November 17th, 2003 11:48 AM
Format Date Time ganesh15 PHP How-To 2 August 20th, 2003 05:26 AM



All times are GMT -4. The time now is 04:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.