Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: timonkYifeng,
Yes, it is true that you have to have your data in the right time/date format to do that comparison. If what you are showing is how your data is listed in your file, it is almost certainly coming in as a "string" type. When you really want a "time" type. Luckily the conversion is simple.
The following code in a Filter node will
1. Update the datatype of the Time field.
2. Emit only the records between the times you have specified.
######
realtime = time('time', "HH:MM:SS")
emit *
where (
realtime > time("15:00:00", "HH:MM:SS") and
realtime < time("15:59:59", "HH:MM:SS)
)
override emit time('time', "HH:MM:SS") as time
######
This example will do what you want. There are a couple ways to make this code a bit more condensed once you are more comfortable. For example you don't really need the extra realtime variable (but it helps when first figuring things out).
##### will do the same thing
emit *
where (
time('time', "HH:MM:SS") > time("15:00:00", "HH:MM:SS") and
time('time', "HH:MM:SS) < time("15:59:59", "HH:MM:SS")
)
override emit time('time', "HH:MM:SS") as time
Either way, you will end up reformatting the 'time' field to a 'time' type, and only emit the records that fall within the range of 15:00:00-15:59:59.
Regards
Timon Koufopoulos
MDA Support.