Results 1 to 7 of 7

Thread: dates in HTML Forms & ASP

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Canada
    Posts
    70

    Question

    Q1
    Does anyone know how to create something similar to a datepicker on an HTML form?
    Is there anything like:
    <input TYPE="Datepicker" NAME="FromDate" VALUE="01 May 2000">


    Q2
    Are there date functions you can use in an asp page.
    For example, I want to format a date [format(date, "dd mm yyyy")] or add a date. When I tried to use these functions I received errors. Can anyone offer a solution?




  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    I'm not sure about the datepicker but you can format dates using the formatdatetime() function, it takes the regional settings from the server though.

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You can embed the actual date time picker control easily. You just have to create a license pack file and embed it on the page as well. The only thing is the page will only be able to be displayed with IE4+

    There are also many javascript versions out there that are browser independent.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  4. #4
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524
    I've used formatdatetime() function...
    but, too bad... the format options is still to limited to choose...
    I can't format my date into :
    22 Sept 2000
    or
    22 September 2000
    or
    09/22/2000
    or
    22/09/2000

    what I can do, just to format my date into longdate or shortdate.

    Any suggestions ???

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Here's a VBScript function I wrote that converts a string converted date in 'MM/DD/YY' format to DD-MMM-YY.

    You could easily modify it to do what you want.

    Code:
    Function ConvertDate(strDateString)
    	Dim intMonth
    
    	on error resume next
    			
    	intMonth = Month(CDate(strDateString))
    
    	Select Case intMonth
    		Case 1
    			strDateString = Day(CDate(strDateString)) & "-JAN-" & Right(Year(CDate(strDateString)),2)
    		Case 2
    			strDateString = Day(CDate(strDateString)) & "-FEB-" & Right(Year(CDate(strDateString)),2)
    		Case 3
    			strDateString = Day(CDate(strDateString)) & "-MAR-" & Right(Year(CDate(strDateString)),2)
    		Case 4
    			strDateString = Day(CDate(strDateString)) & "-APR-" & Right(Year(CDate(strDateString)),2)
    		Case 5
    			strDateString = Day(CDate(strDateString)) & "-MAY-" & Right(Year(CDate(strDateString)),2)
    		Case 6
    			strDateString = Day(CDate(strDateString)) & "-JUN-" & Right(Year(CDate(strDateString)),2)
    		Case 7
    			strDateString = Day(CDate(strDateString)) & "-JUL-" & Right(Year(CDate(strDateString)),2)
    		Case 8
    			strDateString = Day(CDate(strDateString)) & "-AUG-" & Right(Year(CDate(strDateString)),2)
    		Case 9
    			strDateString = Day(CDate(strDateString)) & "-SEP-" & Right(Year(CDate(strDateString)),2)
    		Case 10
    			strDateString = Day(CDate(strDateString)) & "-OCT-" & Right(Year(CDate(strDateString)),2)
    		Case 11
    			strDateString = Day(CDate(strDateString)) & "-NOV-" & Right(Year(CDate(strDateString)),2)
    		Case Else
    			strDateString = Day(CDate(strDateString)) & "-DEC-" & Right(Year(CDate(strDateString)),2)
    	End Select
    
    	ConvertDate = strDateString
    
    End Function
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  6. #6
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Smile

    ok monte...

    I've tried your code...
    It works... but, nd easily to change.... right... I can change / modify your code to what I need easily...

    But, I've got one question for you....
    At your code, you only supply 2 digits of year.
    My question is...

    How about if I want to make my year into 4 digit..
    How can I cek whether it is year 19xx or 20xx ???

    Thx in reply...

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  7. #7
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Code:
    'Change this:
        strDateString = Day(CDate(strDateString)) & "-FEB-" & Right(Year(CDate(strDateString)),2)
    'To this:
        strDateString = Day(CDate(strDateString)) & "-FEB-" & Year(CDate(strDateString))
    'for each case...
    Now, that is assuming that your server's regional settings date format has a 4 digit year otherwise it will still return only a 2 digit year.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width