Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

PERVASIVE - SQL Double - Date REquests

in my Table column DeliveryDate datatype is "DOUBLE" not Date

How can I select the following example

SELECT .... FROM .... WHERE DeliveryDate>='01.01.2021'

Can I Convert CURRENTDATE() to a DOUBLE Value?

thx

question from:https://stackoverflow.com/questions/65933108/pervasive-sql-double-date-requests

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Short answer is that no, you can't just CONVERT a DATE to DOUBLE. If you execute:

select convert(CURDATE(), sql_double)

You will get an error. This is because CURDATE returns a date in the form MMDDYYYY. Because of the slashes, the conversion to Double fails.
You can do something like this:

select convert( concat( DatePart(year,curdate()) , concat(right(concat('00', DatePart(month, curdate())),2) , right(concat('00', DatePart(day, curdate())),2))), sql_double)

But that assumes the DOUBLE is just a YYYYMMDD concatenation of the DATE value.

You need to determine what format your DOUBLE field is and adjust the algorithm to fit your needs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...