If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Char to Date Conversion independent of Regional Settings

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-14-03, 04:01
greypixels greypixels is offline
Registered User
 
Join Date: Aug 2003
Location: Bangalore, India
Posts: 2
Angry 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.
Reply With Quote
  #2 (permalink)  
Old 08-14-03, 12:15
unatratnag unatratnag is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 08-14-03, 15:14
Memnoch1207 Memnoch1207 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 08-22-03, 23:50
greypixels greypixels is offline
Registered User
 
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.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On