Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 10:11 AM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date conversion in Access VBA

Hi all,

I have a two column table in my Access database which is used to store dates. The dates are stored as mm/dd/yy say like 10/13/04. But i want to get the dates passed to a string variable as 101304 i.e without the slashes. The reason being that this string variable is used to pass on this date to an external script file which will only accept the dates as mmddyy i.e again without any slashes or any other symbol in between. I have taken a look at format but i can't see how i can acheive the desired functionality using it. Alternatively is there any way in which i could store the dates in my table as mmddyy so that i do not have to convert it and also retain the property associated with the date type.

Chow
Goels

 
Old October 13th, 2004, 12:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Left([date],2) & Mid([date],4,2) & Right([date],2)

Does this help?



Clive Astley
 
Old October 13th, 2004, 12:26 PM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey thanks Clive. I actually in the meantime found out two ways of doing the same:

(I)
Dim dDate As Date
Dim strText As String
dDate = Date
strText = Replace(CStr(dDate), "/", "")

The replace function finds the slashes ('/') and replaces them with nothing ('')

(II)
Dim dDate As Date
Dim strText As String
dDate = Date
strText = Format(dDate, "mmddyy")

Thanks for your help Clive.

Chow
Goels









Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Conversion ashokparchuri General .NET 2 May 31st, 2005 01:26 AM
Date conversion AFK SQL Language 2 February 4th, 2005 05:14 PM
Date conversion lily611 General .NET 6 December 6th, 2004 12:41 AM
Date Difference in Access VBA amit_jain76 Access VBA 4 January 14th, 2004 11:55 AM
Date in Access VBA (SQL) Kenny Alligood Access VBA 2 September 14th, 2003 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.