Solved

Seperate time from dateTime column in microsoft access

Posted on 2004-08-17
4
255 Views
Last Modified: 2008-03-10
Hi,
I am working on vb.net for windows form and ms access is as backend database.
I am query datatime field from access and show that on dataGrid on form, but I just want to show the time on datagrid and not the whole date and time. How can I make a query so that it retrieve only time part , and not the whole thing. I want to do that in query to access database so that i dont have to do anything on vb.net coding side.
How is it possible? please help.
0
Comment
Question by:greatroni
  • 2
4 Comments
 
LVL 7

Expert Comment

by:rockmuncher
ID: 11827218
to get the date component in a query use

   mydate: clng(datefield())  ' returns a long integer value
or
   mydate: format(clng(datefield()),"Short Date") ' returns text in short date format, or any other format you choose to use  


to get the time component in a query use

   mydate: datefield-clng(datefield())  ' returns a double value
or
   mydate: format(clng(datefield()),"HH:MM:SS") ' returns text in HH:MM:SS format, or any other format you choose to use  
0
 
LVL 7

Expert Comment

by:rockmuncher
ID: 11827224
oops, let me try that again

to get the date component in a query use

   mydate: clng(datefield)  ' returns a long integer value
or
   mydate: format(clng(datefield),"Short Date") ' returns text in short date format, or any other format you choose to use  


to get the time component in a query use

   mydate: datefield-clng(datefield)  ' returns a double value
or
   mydate: format(datefield-clng(datefield),"HH:MM:SS") ' returns text in HH:MM:SS format, or any other format you choose to use  
 
 
change 'datefield' to the name of the field you are concerned about in the query.
 
   
 
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 11827243
you can just use

 yourtime:Format(datefield,"hh:nn:ss")      'this will give you the time
0
 

Author Comment

by:greatroni
ID: 11827296
Thank you so much for this.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

808 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