简体   繁体   中英

How can I join 2 tables with different time formats?

I have the following Command:

OleDbCommand cmd = new OleDbCommand("", Connection);

cmd.CommandText = "SELECT " + Felder + " 
               FROM QS.KO10 LEFT OUTER JOIN QS.FB56 
               ON (KO1007 = FB5601) " + Where;

But this commandtext does not work because it's not enough to connect KO1007 = FB5601 . I have to connect the Datetimes KO1025 and FB5605 too, but the problem is they are in different formats. I would need KO1025 = FB5605 , but KO1025 is YYYYMM and FB5605 is YYMMDD. How do I join these two tables?

KO1007 and FB5601 are just numbers for orders, but these numbers can be more than one time in the datatable, therefore I need to also connect with the two datetime columns to have the exact order.

Lolo的评论很好,我这样做是这样的:

LEFT OUTER JOIN QS.FB56 ON (KO1007 = FB5601 AND SUBSTR(KO1025, 3, 4) = SUBSTR(FB5605, 1, 4)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM