How to return month and year only except days from date?

梦想的初衷 提交于 2019-12-23 00:33:23

问题


i have a particular case of a task that was assigned to me like a week ago and i'm stuck on it.

last week i was told that i have to make that i need to make a search that finds all rows inserted in a determined month of a particular year, let's say i need to return all rows inserted in november of 2019 not specifying the day, that is fine to that point, the tricky part is that usually the database i work on have the dates converted to number, resulting in dates stored something like this "43275" because of the numeric conversión so it makes difficult to search data because it won't match unless it is converted as well.

i tried a couple of methods such as format date time, converting by cdate(most accurate 'till now) but none has done the job, the cdate converts the data to date, but adds the first day making it useless as well, here is a portion of the code i'm trying

numero_mes = request.item("numero_mes")
numero_anio = request.item("numero_anio")
fecha_buscador_cip = cDate(numero_mes &"-"& numero_anio)
buscar_fecha = clng(fecha_buscador_cip)

the result of that code is a conversion similar to what i need but not exactly since the converted date varies since there is a specific date, how can i do the task i'm assigned? i can't find a way yet to do this, any kind of help would be great, thanks in advance.


回答1:


Calculate November 1 and 30 as numbers, and then find all numbers between (and including) those two.

I don’t know your conversion, but let’s say Nov 1 converts to 42501 and Nov 30 is 42530. Do a query for all records WHERE date >= 42501 AND date <= 42530



来源:https://stackoverflow.com/questions/58881370/how-to-return-month-and-year-only-except-days-from-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!