Formatting Question

Results 1 to 2 of 2

Thread: Formatting Question

  1. #1
    Join Date
    Dec 1969

    Default Formatting Question

    I have a form that asks the use for a date and time, and it stores that information in a field on a database:<BR><BR>ddmmmyyyyhhmm (ie. 12Jan20001617 = 12 Jan 2000 4:17 PM)<BR><BR>On this form, I have to make sure that the Day, Hours and Minutes are all at least two characters, and the Year is four. So, if someone enters &#0390&#039 for Minutes, I need to make sure that gets sent to the database as &#03900&#039.<BR><BR>What is the best way to go about this? Should I use some VBScript to format the request.form("fields")? Anyone have any suggestions?<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Formatting Question

    &#062; it stores that information in a field on a database:<BR>&#062;<BR>&#062;ddmmmyyyyhhmm (ie. 12Jan20001617 = 12 Jan 2000 4:17 PM)<BR>&#062;<BR>&#062;What is the best way to go about this? <BR>&#062;<BR><BR>Stop doing this. All databases support date/time data types,<BR>so use that data type instead of a string. One of the MAJOR<BR>problems with your scheme is that the values won&#039t "sort" at <BR>all! That is, in your system December 1st will always<BR>come before January 31st...even if it&#039s Dec 1, 2007 versus<BR>Jan 31, 1832 !!<BR><BR>If you use a date/time datatype in the DB, everything sorts<BR>correctly, you can do meaningful queries against the info,<BR>and--when you pull the data back into ASP using VBScript--<BR>you will end up with Date variables automatically, so that<BR>you can then use all the wonderful builtin VBS functions to<BR>extract info however you want/need it!<BR><BR>Don&#039t work AGAINST what the system gives you. Use what&#039s there<BR>to your advantage.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts