Solved

How to store only time into MSaccess database?

Posted on 2011-03-13
5
346 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now