• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Seperate time from dateTime column in microsoft access

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
greatroni
Asked:
greatroni
  • 2
1 Solution
 
rockmuncherCommented:
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
 
rockmuncherCommented:
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
 
Rey Obrero (Capricorn1)Commented:
you can just use

 yourtime:Format(datefield,"hh:nn:ss")      'this will give you the time
0
 
greatroniAuthor Commented:
Thank you so much for this.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now