How to match two date columns

3 次查看(过去 30 天)
Eg of data:Name of dataset in my workspace is dsColShort
run_date trade_date Volume
735934 732604 100
735934 732655 200
735934 732658 50
735934 732658 100
735934 732689 400
735934 732724 600
735934 735934 700
I need to match up when column 'run_date' == 'trade_date'. I only want to show the row that matches. eg, there will be a 732604 in trade_date column that matches a separate row in run_date column but I do not want those to populate. Only if it's in the same row that they match.
any advice on what function I can use? or if I need to define any of the rows as a separate variable?
Thanks
  5 个评论
Chris H
Chris H 2019-10-17
Hey just figured it out. I was pulling the wrong column name for the actual volumes. Your formula :
idx=dsColShort.run_date==dsColShort.trade_date;
dsColShort(idx,1:3)
pretty much worked so thank you!

请先登录,再进行评论。

采纳的回答

Turlough Hughes
Turlough Hughes 2019-10-17
编辑:Turlough Hughes 2019-10-17
To find the rows in your table, called dsColShort, wherein run_date and trade_date are equal you can use the following code
idx=dsColShort.run_date==dsColShort.trade_date;
We can then use this logical index to return the rows where your condition has been satisifed:
dsColShort(idx,1:3)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by