Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Location
    Bangalore, India
    Posts
    2

    Angry Unanswered: Char to Date Conversion independent of Regional Settings

    Hello,
    * Firstly, how do I convert a string to a Date regardless of the bloody control panel/Regional Settings? I need a way to say that dd is this much, mm is this much and yyyy is this much. (Like JScript new Date(yyyy, mm, dd))
    * Secondly, what kind of idiots are behind VBScript? The usual kind, sophisticated or extreme? Should'nt we have a poll on this.

  2. #2
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    VB is an older language, and vbscript is derived from it so it doesn't have all the features some new languages have. But no one is forcing you to use it, so don't bitch.

    http://www.4guysfromrolla.com/webtech/110398-1.shtml

    if you can't pull what you need from this just do a search on date manipulation vbscript in google. There's lots of functions out there and you just need to find the one you need, if you still can't find what you need make a class.

  3. #3
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    Code:
    strDate = "08/15/2003"
    newDate = CDate(strDate)
    
    getMonth = Month(newDate)
    getDay = Day(newDate)
    getYear = Year(newDate)
    
    display date in (yyyy,mm,dd) format
    newFormatDate = getYear & "/" & getMonth & "/" & getDay
    response.write(newFormatDate)
    will display the date as 2003/8/15 (yyyy,mm,dd)

    if you need to display the 0's then just check the length of the month and day prior to assigning it to the getMonth and getDay variables.

    something like this
    Code:
    if(Len(Month(newDate)) = 1) then
       'month is 1 digit, place a zero in front of it
       getMonth = "0" & Month(newDate)
    else if(Len(Month(newDate)) = 2) then
       'month is 2 digits
       getMonth = Month(newDate)
    end if

  4. #4
    Join Date
    Aug 2003
    Location
    Bangalore, India
    Posts
    2
    What I wanted was a way to explicitly specify each portion of a Date object regardless of the settings in the Control Panel. Cannot use CDate since it interprets its argument depending on the Regional Settings.

    Anyway, got what I wanted:
    DateSerial(year, month. day) and TimeSerial(hour, minute, second)

    Let me know if you want to see the code.

    Thank you all.

Posting Permissions

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