Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-22-2004, 10:46 AM
WebProWorld Member
 

Join Date: Dec 2003
Location: Jackson, MI
Posts: 97
oneeye RepRank 0
Default ASP and Oracle

Does anyone know how to reformat the date so that I can insert a record with .asp into oracle. The format I need is dd-mmm-yyyy . I typically use Dreamweaver to insert data but it doesn't work in this case because of the difference in date format. Any one have some sample asp code that inserts a date field into oracle, or converts the default value of the Date() funtion to the format specified above. I was supposed to have this done last week and am in a real bind. Any help would be greatly appreciated.

Thanks,

Oneeye
__________________
"In the world of the blind the one-eyed man is king."
Reply With Quote
  #2 (permalink)  
Old 01-24-2004, 12:44 PM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default Sample ASP code

Hi there Oneeye,

This article from the 4GuysFromRolla site looks like it should answer your question. They use a function to ensure that no matter what the native environment, the date string will be read in "dd-MMM-yyy" format.

Function MediumDate (str)
Dim aDay
Dim aMonth
Dim aYear

aDay = Day(str)
aMonth = Monthname(Month(str),True)
aYear = Year(str)

MediumDate = aDay & "-" & aMonth & "-" & aYear
End Function


An example showing how you might use it with a database update:

strSQLUpdate = "UPDATE tblOrders " & _
"SET fldDateOrdered = #" & MediumDate( Date() ) & "# " & _
"WHERE fldStatus = open ; "




Let me know how you get on,

Paul
Reply With Quote
  #3 (permalink)  
Old 01-25-2004, 08:50 PM
sma sma is offline
WebProWorld New Member
 

Join Date: Jan 2004
Location: Myanmar
Posts: 5
sma RepRank 0
Default

You'd better use to_date() & to_char() oracle functions to be able to work for any date format setting.
(e.g.
- update my_table set my_date = to_date('20040117', 'yyyymmdd');
- select to_char(my_date, 'yyyy-mon-dd) from my_table;
)
__________________
(0__0)SMA(0__0)
Reply With Quote
  #4 (permalink)  
Old 01-26-2004, 09:25 PM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default

Hi Oneeye,

If you're still having problems, you might want to take a look at the following online tool.
A Gentle Introduction to SQL: INSERT, UPDATE and DELETE
http://sqlzoo.net/howto/oracletip674865.htm
Reply With Quote
  #5 (permalink)  
Old 01-27-2004, 11:20 AM
WebProWorld Member
 

Join Date: Dec 2003
Location: Jackson, MI
Posts: 97
oneeye RepRank 0
Default Thanks

I will giv it a try, Thanks for helping the Oracle Handicapped.

Oneeye
__________________
"In the world of the blind the one-eyed man is king."
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
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

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


Search Engine Optimization by vBSEO 3.2.0