date fields in access database - Forum

Forum Navigation
You need to log in to create posts and topics.

date fields in access database

hello

In the Pro database and Access database. The date type field is not supported.
How do I date a field type and search between two dates?

@s7shanbe

In the Pro database and Access database. The date type field is not supported.
How do I date a field type and search between two dates?

You might store dates in a BigInt field ... and store values as CCYYMMDD ... like ...

19991127
20210214
20200907

... leading zeroes for days/months less than 10 are important.

Note: If it is important for the user to see these dates in their native/cultural format e.g. dd/mm/ccyy or m/d/yy etc., you might consider using two fields ... one that is shown to the user (e.g. in the grid) ... and the other to deploy in the sort process ... just have to make sure that the non-visual field is created/changed in sync with the visual one.

 

Added later ... if I recall correctly, MS Access does not use the Windows Regional Settings when displaying date formats (it only deploys US Date formats) ... if this is still true, you might use a String field for the visual field.

 

luishp and Vadim have reacted to this post.
luishpVadim

@s7shanbe

I don't deal with ACCDB files but using MDB files with DBPro you can only use the DateTime field definition. This can be tricky when searching between dates.

Here's what I do to search in my scheduling program:

:start
DateToNum "[DATEstart]" "m/d/y" "[DATEstartnum]"
DateToNum "[DATEend]" "m/d/y" "[DATEendnum]"
If "[DATEendnum]" "<" "[DATEstartnum]"
AlertBox "" "Invalid Date Range"
GotoLine "end"
EndIf
SetVar "[DATEendnum2]" "[DATEendnum]+1"
NumToDate "[DATEendnum2]" "m/d/yyyy" "[DATEend2]"
SetVar "[DATEtotal]" ""
dbpShowAll "pourschedule" "DATE"

dbpQuery "pourschedule" "DATE" "pourdate BETWEEN DateValue('[DATEstart]') AND DateValue('[DATEend2]')"
dbpShowGrid "pourschedule" "DATE" "Rectangle42"
:end

Using the DBPro popup calendar I select my start and end dates. I had to add a day ([DATEendnum]+1) to my end date because for some reason the query would not include data for my selected end date. You may want to experiment with that.

Hope this helps.