Equal fields Date between tables

Asked

Viewed 28 times

1

In a table I have a Date A field in the format 'dd.mm.yyyy'. In another, date field B in the format yyyymmdd

I want to search all fields where date A equals B

  • The columns are of what type? DATE, DATETIME, VARCHAR?

  • What is the database? Sql Server, Mysql, Oracle ?

  • One field is DATA(DD.MM.YY) and the other numerical (YYYYMMDD).

  • the database is SQL

  • Julio, all these databases are SQL. Mysql, Oracle, SQL Server, DB2, Firebird, Mariadb, HSQL, Derby, Postgresql, Sqlite, etc. Which one are you dealing with?

1 answer

1


Try it like this:

SELECT A.*, B.*
FROM TabelaA A, TabelaB B
WHERE B.datab = YEAR(A.dataa) * 10000 + MONTH(A.dataa) * 100 + DAY(A.dataa)

Whereas the fields you want are dataa table TabelaA and datab table TabelaB.

  • Thank you very much.

  • 1

    @Julio If this answer solved your problem and you have no questions left, mark it as accepted/correct by clicking on " " on the side, which also marks your question as answered/solved. If on the other hand you are not yet satisfied, leave a comment and we will clarify.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.