Converting OpenInsight Date Time to Powershell Date Time

This is a walk through showing the conversion of Date Time values to a Powershell Date Time value.

If you generate your Date Time values in OpenInsight with this format:

OIDateTime = Oconv(Date(),'D2/') : " " : Oconv(Time(),'MTHS')

You'll get a value looking like this:

12/07/15 01:54:37PM

Powershell can convert this format to an internal format with the Get-Date command:

$PSDateTime = Get-Date $OIDateTime

The variable $PSDateTime contains .NET date time reference.

As a bonus, it now becomes much easier to convert the date time value to other formats. Here is an example to convert the value to MySQL DateTime string:

$MySQLDateTime = Get-Date $PSDateTime -Format "yyyy-MM-dd HH:m:ss"

The variable $MySQLDateTime now contains a string "2015-12-07 13:54:37" which can be easily inserted into a standard MySQL datetime column.

Share this post

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

About Us

Congruity Service is a technology solutions company bringing the best technology solutions to OpenInsight projects, Drupal sites, servers, networks, and your technology needs.