Solved

Seperate time from dateTime column in microsoft access

Posted on 2004-08-17
4
252 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 119

Accepted Solution

by:
Rey Obrero 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

743 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

12 Experts available now in Live!

Get 1:1 Help Now