Dear all,
I am really confused with Access Date field handling.
I have the following query (assume TableA has a field "wdays" which stores all the dates in Year 2009):
select top 1 format(wdays,'dd/mm/yyyy') as wdays1
from TableA
where year = 2009
and WDays >= format('10/04/2009', 'dd/mm/yyyy')
order by wdays asc
It will select 11/04/2009 which is fine.
But in case i use this SQL:
select top 1 format(wdays,'dd/mm/yyyy') as wdays1
from TableA
where year = 2009
and format(WDays,'dd/mm/yyyy') >= format('10/04/2009', 'dd/mm/yyyy')
order by wdays asc
the select behaviour will be totally different. It will select 12/01/2009! (I don't know why it is 12/01/2009)
I am very confused with the function: "FORMAT" now..
I have a VB program which has a lot of queries.
Some of the queries sometimes use:
format(mydate,'dd/mm/yyyy') = format(v_inputdate,'dd/mm/yyyy')
Or Some of them just simply use:
mydate=v_inputdate
Or Some use:
mydate = format(v_inputdate,'dd/mm/yyyy')
Or some use
format(mydate,'dd/mm/yyyy') = v_inputdate
Would you mind please teach me what is the best practise for writing select, update, delete, insert sql statements when date or datetime fields are included in the conditions?
Many Many thanks.. I am super urgent to know the answer.
I am really confused with Access Date field handling.
I have the following query (assume TableA has a field "wdays" which stores all the dates in Year 2009):
select top 1 format(wdays,'dd/mm/yyyy') as wdays1
from TableA
where year = 2009
and WDays >= format('10/04/2009', 'dd/mm/yyyy')
order by wdays asc
It will select 11/04/2009 which is fine.
But in case i use this SQL:
select top 1 format(wdays,'dd/mm/yyyy') as wdays1
from TableA
where year = 2009
and format(WDays,'dd/mm/yyyy') >= format('10/04/2009', 'dd/mm/yyyy')
order by wdays asc
the select behaviour will be totally different. It will select 12/01/2009! (I don't know why it is 12/01/2009)
I am very confused with the function: "FORMAT" now..
I have a VB program which has a lot of queries.
Some of the queries sometimes use:
format(mydate,'dd/mm/yyyy') = format(v_inputdate,'dd/mm/yyyy')
Or Some of them just simply use:
mydate=v_inputdate
Or Some use:
mydate = format(v_inputdate,'dd/mm/yyyy')
Or some use
format(mydate,'dd/mm/yyyy') = v_inputdate
Would you mind please teach me what is the best practise for writing select, update, delete, insert sql statements when date or datetime fields are included in the conditions?
Many Many thanks.. I am super urgent to know the answer.
Last edited: