Example Code

Converting the Date/Time String in the Database Toolset to the SQL Query Format

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Database Connectivity Toolkit
  • LabVIEW

Code and Documents

Attachment

Overview

You can use the attached VI to convert strings that are output as a date/time yyyy-mm-dd hh:mm:ss format from the "DB Tools Format Datetime Str VI" to a mm/dd/yyyy hh:mm:ss AM/PM format that is accepted by a SQL query.

 

Description

This can be used as a subVI in a larger application that uses the Database Connectivity Toolkit. The VI reads in a string input from the "DB Tools Format Datetime Str VI" and uses several "Search/Split String VIs" to break apart the current format. Then the VI concatenates all of the strings back to a single string output in a format that is accepted by a SQL query.

 

Requirements

  • LabVIEW 2012(or compatible)
  • Database Connectivity Toolkit (Only if used as a SubVI)

 

Steps to Implement or Execute Code

  1. Enter the desired string input on the front panel
  2. Run the VI

 

Additional Information or References

 

VI Snippet

1.png

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,
Margaret Barrett
National Instruments
Applications Engineer
Digital Multimeters and LCR Meters

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Todd S.
NI Employee (retired)
on

Could you include a screenshot of the code?  Thanks!

Todd S.
LabVIEW Community Manager
National Instruments
thad_tensentric
Member
Member
on

The AM/PM should be calculated if the hour is greater than 11, not 12.  12:00:00-23:59:59 is PM.