A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I convert number to a date format in MS Access



 
 
Thread Tools Display Modes
  #1  
Old May 11th, 2006, 08:22 AM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default How do I convert number to a date format in MS Access

I am having a number field in yyyymmdd format. wants to convert into date
field as yyyy/mm/dd in MS Access
thanks for the help

  #2  
Old May 11th, 2006, 08:42 AM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default How do I convert number to a date format in MS Access

Hello there,

One way is to create a Query, add your field in the desing view and create
also another field as follows:

MyDate: Left([YourFieldName];4) & "/" & Mid([YourFieldName];5;2) & "/" &
Right([YourFieldName];2)

You can now use the query to update a newly created field in your table.

Hope this helps.

George


Ο χρήστης "chinky" *γγραψε:

I am having a number field in yyyymmdd format. wants to convert into date
field as yyyy/mm/dd in MS Access
thanks for the help

  #3  
Old May 11th, 2006, 03:04 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default How do I convert number to a date format in MS Access

I try not to write expressions that don't explicitly change data from one
type to another and then back again. I also don't like to create complex
expressions/calculations that might be useful in several places in an
application. Consider using a small function like the following which you
can paste into a new module and save it as "basDateConversions". Then, in a
query, you can call it like:

TrueDate: ConvertYMD([YourYYYYMMDDFieldName])

Function ConvertYMD(varDate As Variant) As Date
Dim intYear As Integer
Dim intMth As Integer
Dim intDay As Integer
If IsNull(varDate) Then
ConvertYMD = 0
Else
intYear = varDate \ 10000
intMth = (varDate Mod 10000) \ 100
intDay = varDate Mod 100
ConvertYMD = DateSerial(intYear, intMth, intDay)
End If
End Function

--
Duane Hookom
MS Access MVP

"chinky" wrote in message
...
I am having a number field in yyyymmdd format. wants to convert into date
field as yyyy/mm/dd in MS Access
thanks for the help



  #4  
Old May 11th, 2006, 04:09 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default How do I convert number to a date format in MS Access

Thanks George for timely help. Yes I was able to do what I wanted to do.

"chinky" wrote:

I am having a number field in yyyymmdd format. wants to convert into date
field as yyyy/mm/dd in MS Access
thanks for the help

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update a number field incrementally AllyOop Running & Setting Up Queries 7 February 22nd, 2006 12:38 PM
Converting number or text to a Date Format samhain New Users 2 October 17th, 2005 02:28 PM
Converting Date Format from YYYY-MM-DD to Access date format activegirl General Discussion 3 June 21st, 2005 11:03 PM
Need Subforms? AccessRookie Using Forms 7 April 8th, 2005 09:30 AM
incorrect sums in report using 2 tables jkendrick75 Setting Up & Running Reports 22 December 13th, 2004 02:19 PM


All times are GMT +1. The time now is 02:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.