Solved

Seperate time from dateTime column in microsoft access

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

813 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

10 Experts available now in Live!

Get 1:1 Help Now