Connecting Tech Pros Worldwide Forums | Help | Site Map

Date Queries - #10/01/2004# - #1/10/2004#

CLarkou
Guest
 
Posts: n/a
#1: Nov 13 '05
I have a field with dates in an Access database. The format of date is
short date "19/06/2004". In my regional settings I have as date format
"dd/mm/yyyy".

When I create a query from design to get the data from 10/01/2004 in
criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
which is opposite.

The problem is that I am creating query from VBA and by settings date
to be #10/01/2004#, I don't get any records. When I create it from
DESIGN I get results.

Is there a reason for this ?

PC Datasheet
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


When using #'s, dates must be in the American format of MM/DD/YYYY.
(Courtesy of Chuck Grimsby)

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com



"CLarkou" <clarkou@memrb.com.cy> wrote in message
news:db08d9f5.0410182138.580f84bb@posting.google.c om...[color=blue]
> I have a field with dates in an Access database. The format of date is
> short date "19/06/2004". In my regional settings I have as date format
> "dd/mm/yyyy".
>
> When I create a query from design to get the data from 10/01/2004 in
> criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
> which is opposite.
>
> The problem is that I am creating query from VBA and by settings date
> to be #10/01/2004#, I don't get any records. When I create it from
> DESIGN I get results.
>
> Is there a reason for this ?[/color]


Christina Larkou
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


Thanks a lot, I will try it and let you know.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Terry Bell
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


You might find these handy:

Function MakeUSDate(x As Variant)
If Not IsDate(x) Then Exit Function
MakeUSDate = "#" & Format(Month(x), "00") & "/" & Format(Day(x), "00")
& "/" & Format(Year(x), "0000") & "#"
End Function

Public Function MakeUSDateTime(InDateTime) As String
'returns a datestring in the form #mm/dd/yy hh:nn# - to the minute
Dim a As String, b As String, c As String, Tm As String
a = MakeUSDate(InDateTime)
b = Left(a, Len(a) - 1)
Tm = Format(DatePart("h", InDateTime), "00") & ":" &
Format(DatePart("n", InDateTime), "00")
MakeUSDateTime = b & " " & Tm & "#"
End Function

Public Function MakeUSDateExactTime(InDateTime) As String
'returns a datestring in the form #mm/dd/yy hh:nn# - to the second
Dim a As String, b As String, c As String, Tm As String
a = MakeUSDate(InDateTime)
b = Left(a, Len(a) - 1)
Tm = Format(DatePart("h", InDateTime), "00") & ":" &
Format(DatePart("n", InDateTime), "00") & ":" & Format(DatePart("s",
InDateTime), "00")
MakeUSDateExactTime = b & " " & Tm & "#"
End Functionclarkou@memrb.com.cy (CLarkou) wrote in message news:<db08d9f5.0410182138.580f84bb@posting.google. com>...[color=blue]
> I have a field with dates in an Access database. The format of date is
> short date "19/06/2004". In my regional settings I have as date format
> "dd/mm/yyyy".
>
> When I create a query from design to get the data from 10/01/2004 in
> criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
> which is opposite.
>
> The problem is that I am creating query from VBA and by settings date
> to be #10/01/2004#, I don't get any records. When I create it from
> DESIGN I get results.
>
> Is there a reason for this ?[/color]
Terry Bell
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


You might find these handy:

Function MakeUSDate(x As Variant)
If Not IsDate(x) Then Exit Function
MakeUSDate = "#" & Format(Month(x), "00") & "/" & Format(Day(x), "00")
& "/" & Format(Year(x), "0000") & "#"
End Function

Public Function MakeUSDateTime(InDateTime) As String
'returns a datestring in the form #mm/dd/yy hh:nn# - to the minute
Dim a As String, b As String, c As String, Tm As String
a = MakeUSDate(InDateTime)
b = Left(a, Len(a) - 1)
Tm = Format(DatePart("h", InDateTime), "00") & ":" &
Format(DatePart("n", InDateTime), "00")
MakeUSDateTime = b & " " & Tm & "#"
End Function

Public Function MakeUSDateExactTime(InDateTime) As String
'returns a datestring in the form #mm/dd/yy hh:nn# - to the second
Dim a As String, b As String, c As String, Tm As String
a = MakeUSDate(InDateTime)
b = Left(a, Len(a) - 1)
Tm = Format(DatePart("h", InDateTime), "00") & ":" &
Format(DatePart("n", InDateTime), "00") & ":" & Format(DatePart("s",
InDateTime), "00")
MakeUSDateExactTime = b & " " & Tm & "#"
End Functionclarkou@memrb.com.cy (CLarkou) wrote in message news:<db08d9f5.0410182138.580f84bb@posting.google. com>...[color=blue]
> I have a field with dates in an Access database. The format of date is
> short date "19/06/2004". In my regional settings I have as date format
> "dd/mm/yyyy".
>
> When I create a query from design to get the data from 10/01/2004 in
> criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
> which is opposite.
>
> The problem is that I am creating query from VBA and by settings date
> to be #10/01/2004#, I don't get any records. When I create it from
> DESIGN I get results.
>
> Is there a reason for this ?[/color]
Douglas J. Steele
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


Why bother with functions like that, Terry? All you need is the built-in
Format function.

See http://www.mvps.org/access/datetime/date0005.htm at "The Access Web" for
a far simpler approach.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Terry Bell" <dreadnought8@hotmail.com> wrote in message
news:923537d6.0410190531.115b7af7@posting.google.c om...[color=blue]
> You might find these handy:
>
> Function MakeUSDate(x As Variant)
> If Not IsDate(x) Then Exit Function
> MakeUSDate = "#" & Format(Month(x), "00") & "/" & Format(Day(x), "00")
> & "/" & Format(Year(x), "0000") & "#"
> End Function
>
> Public Function MakeUSDateTime(InDateTime) As String
> 'returns a datestring in the form #mm/dd/yy hh:nn# - to the minute
> Dim a As String, b As String, c As String, Tm As String
> a = MakeUSDate(InDateTime)
> b = Left(a, Len(a) - 1)
> Tm = Format(DatePart("h", InDateTime), "00") & ":" &
> Format(DatePart("n", InDateTime), "00")
> MakeUSDateTime = b & " " & Tm & "#"
> End Function
>
> Public Function MakeUSDateExactTime(InDateTime) As String
> 'returns a datestring in the form #mm/dd/yy hh:nn# - to the second
> Dim a As String, b As String, c As String, Tm As String
> a = MakeUSDate(InDateTime)
> b = Left(a, Len(a) - 1)
> Tm = Format(DatePart("h", InDateTime), "00") & ":" &
> Format(DatePart("n", InDateTime), "00") & ":" & Format(DatePart("s",
> InDateTime), "00")
> MakeUSDateExactTime = b & " " & Tm & "#"
> End Functionclarkou@memrb.com.cy (CLarkou) wrote in message[/color]
news:<db08d9f5.0410182138.580f84bb@posting.google. com>...[color=blue][color=green]
> > I have a field with dates in an Access database. The format of date is
> > short date "19/06/2004". In my regional settings I have as date format
> > "dd/mm/yyyy".
> >
> > When I create a query from design to get the data from 10/01/2004 in
> > criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
> > which is opposite.
> >
> > The problem is that I am creating query from VBA and by settings date
> > to be #10/01/2004#, I don't get any records. When I create it from
> > DESIGN I get results.
> >
> > Is there a reason for this ?[/color][/color]


Terry Bell
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Date Queries - #10/01/2004# - #1/10/2004#


Mainly because I didn't know of that method - I was just trying to
save the poster some work, as the first reply didn't suggest a
solution.
Thanks for the tip anyway


"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message news:<18adnReVjLZ6GejcRVn-1Q@rogers.com>...[color=blue]
> Why bother with functions like that, Terry? All you need is the built-in
> Format function.
>
> See http://www.mvps.org/access/datetime/date0005.htm at "The Access Web" for
> a far simpler approach.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
>
> "Terry Bell" <dreadnought8@hotmail.com> wrote in message
> news:923537d6.0410190531.115b7af7@posting.google.c om...[color=green]
> > You might find these handy:
> >
> > Function MakeUSDate(x As Variant)
> > If Not IsDate(x) Then Exit Function
> > MakeUSDate = "#" & Format(Month(x), "00") & "/" & Format(Day(x), "00")
> > & "/" & Format(Year(x), "0000") & "#"
> > End Function
> >
> > Public Function MakeUSDateTime(InDateTime) As String
> > 'returns a datestring in the form #mm/dd/yy hh:nn# - to the minute
> > Dim a As String, b As String, c As String, Tm As String
> > a = MakeUSDate(InDateTime)
> > b = Left(a, Len(a) - 1)
> > Tm = Format(DatePart("h", InDateTime), "00") & ":" &
> > Format(DatePart("n", InDateTime), "00")
> > MakeUSDateTime = b & " " & Tm & "#"
> > End Function
> >
> > Public Function MakeUSDateExactTime(InDateTime) As String
> > 'returns a datestring in the form #mm/dd/yy hh:nn# - to the second
> > Dim a As String, b As String, c As String, Tm As String
> > a = MakeUSDate(InDateTime)
> > b = Left(a, Len(a) - 1)
> > Tm = Format(DatePart("h", InDateTime), "00") & ":" &
> > Format(DatePart("n", InDateTime), "00") & ":" & Format(DatePart("s",
> > InDateTime), "00")
> > MakeUSDateExactTime = b & " " & Tm & "#"
> > End Functionclarkou@memrb.com.cy (CLarkou) wrote in message[/color]
> news:<db08d9f5.0410182138.580f84bb@posting.google. com>...[color=green][color=darkred]
> > > I have a field with dates in an Access database. The format of date is
> > > short date "19/06/2004". In my regional settings I have as date format
> > > "dd/mm/yyyy".
> > >
> > > When I create a query from design to get the data from 10/01/2004 in
> > > criteria I type #10/01/2004#. In SQL I checked and had #1/10/2004#
> > > which is opposite.
> > >
> > > The problem is that I am creating query from VBA and by settings date
> > > to be #10/01/2004#, I don't get any records. When I create it from
> > > DESIGN I get results.
> > >
> > > Is there a reason for this ?[/color][/color][/color]
Closed Thread


Similar Microsoft Access / VBA bytes