Date and time data get stored in all sorts of ways. One of the more frustrating issues is that some common GIS formats (Shapefiles) can't store date and time in the same field without making it a string. This is fine for visual display but terrible for use with tools that use DateTime for their functionality, such as the TimeManager Plugin (refer to Chapter 4, Data Exploration).
Use datetime-example.shp, which contains a variety of date and time representations to play with.
datetime-example.shp.datetime-example.calculated).substr String operation (that is, Substring) in combination with the || concatenation to rearrange the values from existing fields into a valid DateTime:shpDate with Time and put a space in between:"shpdate" || ' '|| "Time"
Date: substr("Date",7,4) ||'-'||substr("Date",1,2)||'-'|| substr("Date",4,2) || ' '|| "Time"
Substr takes three arguments: the field name, the starting position, and the number of characters after this to include. The position index starts at 1.
Using string manipulation, we've combined multiple fields into an ISO standard format for DateTime, which other tools will recognize and be able to utilize.
The fields included in this example data are as follows:
|
Field |
Type |
Explanation |
|---|---|---|
|
|
String |
This is time in a 24 hour format: hours:minutes:seconds. |
|
|
String |
This is a |
|
|
String |
This is a String that is long enough to hold date and time with padding characters and a timezone UTC offset. |
|
|
String |
This is a typical date format coming out of a spreadsheet. |
|
|
Date |
This is a date format in the |