Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Wednesday, April 16, 2014

SQL : Get Last Update TimeStampe For A Table


I have some Oracle tables that have no datestamp on them that would display the last update of that row.  Here is a query for that:

SELECT SCN_TO_TIMESTAMP( ORA_ROWSCN )
FROM YOURTABLE;

Sample output would look something like:

4/16/2014 9:01:26.000000000 AM

Of course, you can add a where clause to determine update for your particulars.

For more information: SCN_TO_TIMESTAMP

Friday, March 28, 2014

NET : Formatting A Date For Oracle

Currently, developers must provide date format whenever inserting date records into oracle.  Here is one approach:


public static DateTime FormatDateForOracle(string inDate)
  {
  //try to parse date into the acceptable Oracle format
  DateTime parsedDate;

  if (DateTime.TryParse(inDate, out parsedDate))
  {
    try
        {
          return parsedDate =       DateTime.ParseExact(Convert.ToDateTime(inDate).ToString("MM/dd/yyyy"), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
        }
    catch (Exception e)
        {
          //Handle as you see fit
        }
  }
  else
    {
       //Handle as you see fit
    }
    return parsedDate;
}