简体   繁体   中英

convert SQL string into a date that can be queried

I am pulling from a database using the following:

SELECT
ID, CUSTOMER, NAME, etc, etc, TERM_INDEX
FROM "DAB055.ADT" DAB055

Now I want to limit the date range we pull, so would like to do something like:

WHERE TERM_INDEX >= '01.01.2015'

but the output in that field looks like:

20150629W

How can I convert that into a usual date field within the same statement, so that it can be filtered on?

Thanks.

It looks like your dates are stored in a format that will sort chronologically by using the alphabetical order. You can probably just say WHERE TERM_INDEX >= '20150101' .

Also it shouldn't be difficult to grab the first 8 characters and convert to a date type. Without knowing which platform you're on we'd have to guess at the syntax though.

One of these might work to figure out what your database server is:

select @@version
select * from v$version

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