Solved

How to store only time into MSaccess database?

Posted on 2011-03-13
5
349 Views
Last Modified: 2012-05-11
Hello,

I have  an application with Access database. In database I need to query records between ONLY times.
I have in vb.net code on Button_click like this:
OnlyTimeTextBox.text = TimeString

Open in new window

But, when I save record, then database get value like 13.3.2011 19:05:10.

How can I get only time?
My goal is to query like. But, of course it is not working, because the Date is also include.
Between #7:00:00# and #8:00:00#

Open in new window


Thank you in advance for help to anyone.
0
Comment
Question by:dejandejanovic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:AkAlan
ID: 35123115
Have you tried using the datepart function

where datepart("hh"YourDateField) BETWEEN #7#  AND #8#

you may have to play with parenthasis and pound sign
0
 
LVL 6

Expert Comment

by:AkAlan
ID: 35123123
Forgot the comma
datepart("hh",YourDateField)
0
 
LVL 6

Accepted Solution

by:
AkAlan earned 500 total points
ID: 35123133
Also, Remember that you are only extracting the Hour part (hh) so don't ask with colons like this #08:00:00#  because it is only looking for integers.
0
 

Author Closing Comment

by:dejandejanovic
ID: 35123322
It works perfect. I could not remember for this solution.
Thank you AkAlan.

This is Access version of the AkAlan code, if someone else maybe need it:
[code]DatePart("h";[YourDateField])[/code]
0
 

Author Comment

by:dejandejanovic
ID: 35123335
DatePart("h";[YourDateField])

Open in new window


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question