CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Insert current date in oracle for in classifieds

Print topic Send  topic

Author Message
Cyril
Posted: 03/19/2002, 7:34 AM

How can I insert the current date/time to the date_posted field if I am using Oracle database?
Ken Hardwick
Posted: 03/19/2002, 4:39 PM

Cyril,
I've been working with Oracle and CC for last year. Add the following two functions to your global functions. Then, use your date fields just like any other database.

For your specific example, in your before update and/or before insert events.
Just set your field to current date/time..like
fldDate_Posted = now

Note that this will use the data on your web server or maybe your workstation not your oracle server. If you want to use your oracle server, you would need to do it some other way. In a straight SQL it would be "date_Posted = sysdate"
And if you wanted/needed the oracle date, you would need to modify the ToSQL function...like add..
if Value = "sysdate" then
ToSQL = "sysdate"
else
....all the other orignal if statements etc...
end if

Hope this helps.....
Ken Hardwick


Function ToSQL(Value, sType)
Dim Param : Param = Value
if Param = "" then
ToSQL = "Null"
else

if sType = "Number" then
ToSQL = replace(CDbl(Param), ",", ".")
else
if sType = "Date" then
ToSQL = OracleDate(Param)
else
ToSQL = "'" & Replace(Param, "'", "''") & "'"
end if
end if
end if
end function


Function OracleDate(newDate)

'This function convert date to oracle date format
Dim dtTemp
dim dtTime
If newDate <> "" Then
If Day(newDate) < 10 Then
dtTemp = "0"
End If

dtTemp = dtTemp & Day(newDate) & "-" & UCase(Trim(MonthName(Month(newDate),4))) & "-" & Right(Year(newDate),4)

End If

dtTime = FormatDateTime(newDate,4) & ":" & right("0"& second(newdate),2)


dtTemp = "To_date('" & dttemp & ":" & dttime & "','DD-MON-YYYY hh24:mi:ss')"


OracleDate = dtTemp

End Function

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.